Tab filename completion
(Redirected from Tab completion)
Jump to navigation
Jump to search
When you use the bash shell on Linux it will complete commands and file names for you if you type the 'TAB' key. The default behaviour is:
- You type in the start of the command or filename.
- You hit TAB.
- The shell will fill in as much as it can and beep.
- Hit TAB again and it shows you all possible matches.
Example:
- You want to start firefox and type only firef and then the 'TAB' key.
- You want to know which commands starting with 'f' exist, so you type 'f' and then the 'TAB' key twice.
Configuration
The default behavior be changed to:
- You type in the start of the command or filename.
- You hit TAB.
- The shell will fill in as much as it can and shows you all possible matches.
All that needs to be done is:
- Edit /etc/inputrc
- Add the line:
set show-all-if-ambiguous on
Problems
Tab filename completion does not work in some scenarios.
- Example
- You are an ordinary user. You oPen a console and type
sudo cp /root/
and then the 'TAB' key. bash will try to complete the filename, but you as a user are not allowed to see the files in the /root folder. Bash filename completion will not work for this reason.
- Example
- You want to copy from the network
scp root@192.168.0.1:/tmp/
then the 'TAB' key does not work.