Update 2008-03-25 @ 00:32: This post was originally titled "Emulate Command Prompt (cmd) tab auto-completion behaviour in Linux terminal (Bash)" (originally posted on 2008-03-20 @ 23:45), and have since been updated to cover more grounds.
Being a long time Windows command prompt (cmd) user, there are 2 things that the Linux terminal really annoyed me – tab auto-completion and case-sensitivity.
For instance, if you have "file-1.txt", "file-2.txt" and you do "fi[tab]", you’d get "file-", instead of "file-1.txt". And if you try doing something like "ls -l File*" you wouldn’t get anything returned…
Luckily, you can change the above behaviour by editing 2 files.
In order to get the windows command prompt’s tab-completion behaviour, you can edit / adding the following to "/etc/inputrc" (or "~/.inputrc"):
# Tab TAB: menu-complete # Shift-Tab (reverse menu-complete) "e[Z": "e--t" # Ignores the case of the letter set completion-ignore-case on
According to the blog entry where I got this from, the "–" part of the Shift-TAB entry acts as an argument to the menu-complete function. In this case, it takes the previous entry of menu-complete.
Also, to enhance the terminal, you can also make the following amendments:
# The old style auto-complete (now mapped to Ctrl+space) - so you can still use it... Control-SPACE: complete # Automatically show everything instead of you having to press Ctrl+Space (as configured here) twice... set show-all-if-ambiguous on set show-all-if-unmodified on # Display a "/" at the end for symlinked directories set mark-symlinked-directories on # Shut the bell up... set bell-style none
Case-insensitive expansion ("globbing"):
If you want "ls -ld File*" to also display "file-1.txt", "file-2.txt", as well as "FiLe.txt" and "FILE.txt", you can add the following to "/etc/bash.bashrc":
# Disable case sensitive expansion - for command like "ls ld a*" to list "A_file" # Note for things like "ls -ld a_file.txt", we still need to force it to glob by "ls -ld [a]_file.txt" shopt -s nocaseglob
However, as mentioned in the comments, listing a complete filename is still sensitive – you’d have to force it to glob by doing "ls -ld [a]_file.txt".
If you know of any other useful modifications, drop me a comment!