Bash Completion is a powerful CLI magic for bash user, it allows users to hit tabs and have auto completions on command lines. If you have no idea what is bash completion, check out CLI magic: programmable bash completion.
One of the features bash completion gives you is to hide the unknown file format from tab completions. For example, If I want to untar something, I type
tar -zxvf (tab)(tab)
I do not expect to see others file listed besides those files with file extension .tar.gz. Therefore, bash completion intelligently filter it off. So what is the tip I wanna share here?
What if I want a command to list some specific file extension which by default it doesn’t? Ok, here I give you an example. I have kaffeine to play video files. I like to trigger kaffeine from terminal, so that I can browse the files and play it instantly.
By default, bash completion on kaffeine does not support .flv ( flash video file format which downloads from youtube.com ). So, how am I suppose to add flv into kaffeine bash completion?
sudo vi /etc/bash_completion
Edit /etc/bash_completion , it doesn’t matter what editor you use, as long as you can search “kaffeine”.
The line will looks as below, with changes in bold.
complete -f -X '!*.@(mp?(e)g|MP?(E)G|wma|avi|AVI|asf|vob|VOB|bin|dat|vcd|ps|pes|fli|flv|viv|rm|ram|yuv|mov|MOV|qt|QT|wmv|mp3|MP3|ogg|OGG|ogm|OGM|mp4|MP4|wav|WAV|asx|ASX|mng|MNG|srt)' xine aaxine fbxine kaffeine
Restart my terminal, and now bash completion on kaffeine supports .flv.