In a recent article, we talked about Gogo – a tool to create shortcuts for long paths in a Linux shell. Although gogo is a great way to bookmark your favorite directories inside a shell, however, it has one major limitation; it lacks an auto-completion feature.
Because of the above reason, we went all out to find a similar utility with auto-completion support – where the shell can prompt with suggestions of the available aliases (shortcuts to long and complicated paths) and luckily, after crawling through Github, we discovered Goto.
Goto is a shell utility to quickly navigate to aliased directories, with support for auto-completion. It comes with a nice auto-completion script so that once you press the tab key after the goto command or after typing a few charters of an existing alias, bash or zsh prompts with suggestions of the aliases or auto complete the name, respectively.
Goto also has additional options for unregistering an alias, expanding an alias’s value as well as cleaning up aliases of deleted directories. Note that goto’s auto-completion only works for aliases; it is separate from shell auto-completion for commands or filenames.
How to Install and Use Goto in Linux Systems
To install Goto, start by cloning the goto repository from Github and move into the local repository directory, then run the install shell script with root user privileges using the sudo command as shown.
$ cd Downloads/ $ git clone https://github.com/iridakos/goto.git $ cd goto $ ls $ sudo ./install
This will install goto in /usr/local/share/goto.sh, and it will add a line in your
~/.bashrc (for Bash) or
~/.zshrc (for Zsh) shell startup file, to source it.
Now restart your terminal to start using goto. To create an alias for a directory, register the alias with the
-r flag as follows.
$ goto -r march ~/Documents/Tecmint.com-Articles/March/
To alias your current directory, use this syntax which will automatically be aliased to the whole path.
$ goto -r home .
When you type goto and press the tab key, it will show all registered aliases and when you type a few letters of a registered alias, goto will auto complete the name. However, to view a list of your currently registered aliases, use the
$ goto -l
To expand an alias to its value using the following command.
$ goto -x scripts $ goto -x march
Goto also allows you to unregister an alias, using the
$ goto -l $ goto -u march $ goto -l
If you have removed aliased directories (for example if you have deleted the directories ~/Documents/Tecmint.com-Articles/March and ~/bin/shellscripts/recon from the filesystem), yet they still have aliases in goto, you can cleanup all these aliases from goto with the
$ goto -c
A significant limitation of goto is that it doesn’t allow for accessing a sub-directory under an aliased directory, which is a feature present in Gogo.
For more information, consult the goto help message with the
$ goto -h
Goto Github repository: https://github.com/iridakos/goto
Goto is a powerful way to bookmark your favorite directories inside a shell, with auto-completion support, in Linux. It has more useful features compared to Gogo, as explained above. Give it a try and share with us, your thoughts about it via the feedback form below.