If I want to navigate inside folder with long hard-to-type name, is there way to use cd with some kind of shortened name of this folder, to get free from unnecessary work?
- 30,396
- 15
- 136
- 260
- 165
- 1
- 1
- 11
4 Answers
The easiest solution would be to just press Tab to autocomplete folder names from the typed prefix, i.e. you type:
cd Foo
then press Tab, and it should complete with the first matching folder name.
As an alternative, Autojump is probably not the solution you directly asked for, but it's probably the most useful for changing folder names. It learns which folders you use frequently, and you can jump to them via entering:
j Foo
It will change to the folder based on that (part) name. You can limit the search to child directories with jc:
jc Foo
Note: It used to be possible to pass multiple arguments to bash, e.g. you could do cd Foo*, and that would expand to all matches of Foo*, where cd would change to the first of the arguments. However, with recent versions of cd this is no longer possible, resulting in an error: cd: too many arguments.
- 235,242
There are various shells and shell extensions that support partial path autocomplete and fish is one of them beside zsh. For example cd /v/l/fsck Tab will convert the path to /var/log/fsck/. cd /u/s/appl Tab will expand the path to /usr/share/applications/
You can also use some fuzzy search software like
-
This bash completion module performs "fuzzy" matching similar to textmate's "Go to File" fuzzy matching, "flex matching" in emacs' ido mode, etc.
mkdir pizza mkdir jazz cd zz<TAB> # displays `pizza' and `jazz' rm -r jazz cd zz<TAB> # completes the word `pizza' fzf: a general-purpose command-line fuzzy finder. Just press Alt-C to cd into the selected directory
Command-T: Command-T for shell
Command-T is a Vim plug-in that provides an extremely fast "fuzzy" mechanism for:
- 30,396
- 15
- 136
- 260
You can try use zsh, it has advanced command completion features
cd /u/sh/lo + tab = cd /usr/share/locale
Also we can use zsh hash aliases and other magic zsh functions)
https://github.com/robbyrussell/oh-my-zsh https://github.com/zsh-users/zsh-completions
- 30,396
- 15
- 136
- 260
- 11
- 1

