Command completion in bash(1) is quite handy; I like this feature very much. But I have a question.
For example, we all have Documents and Downloads in $HOME directory.
So if I input cd ~ and then press TAB, then it will traverse all the directory under $HOME. When Documents come up and the shell now displays cd ~/Documents, I want to go deeper into this directory. For example, there is a work directory in Documents. My intention is to cd to the work directory.
So what should I do?
I usually input a w then press TAB, but when this action repeats too much I found it quite annoying. And sometimes I don’t know exactly what files are under this directory.
Do you have any good ideas?
ps: In fact, i met this problem when i was using vim. I input :e then TAB, it will cycle the subfolders, the only way i found to stop the cycling and enter the next level is input a /. So the path has double ‘/’ in the end.
You could switch your shell to ZShell, which allows you to tab through directories without typing the first letter.
For example, you can type
Pressing TAB will bring up a list of all subfolders (like in bash), but pressing TAB multiple times will allow you to cycle through the subfolders. Pressing the -> or / key will allow you to start tab-completing inside that directory, and so on.
You can sometimes use
chsh(man chsh for more info) to change your shell, if it’s your own personal machine, or your network might have a special way to change your shell. You might also want to Google for some common.zshrc/.zshenvsettings or migrate your old.bashrc/.cshrc/.profilesettings.Zsh also has ways to set up TAB completion for other tasks, for example, it can TAB complete svn files based on those that aren’t already in SVN (for
svn add). To get these features, addto your .zshrc file. There are plenty more ways to customize your TAB completion in zsh (such as with case-insensitivity, or for arguments to different programs), but if you’re interested in those, you can probably find more information than I know by searching.