I finally added autocompletion for my TV channels for mplayer which is far superior to my previous method of looking up the exact channel’s name in my channels.conf and typing mplayer dvb://”channel’s name” in a terminal.
I just added this very simple script to /etc/bash-completion.d/
_channel() { local cur COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" local chans=$(cat .mplayer/channels.conf |sed -ne 's/^\([^:]*\).*/"\1"/p') oifs="$IFS" IFS=$'\n' COMPREPLY=($(compgen -W "${chans}" $cur)) IFS="$oifs" } complete -F _channel channel
Then I added the following to my .bashrc:
function channel { mplayer dvb://"$1" }
So it’s channel “<TAB> for me now.
Done.