Goto – Quickly Navigate to Aliased Directories with Auto-Completion Support

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.

Goto - Navigate Quickly to Aliased Directories

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/
Create Alias for Directory in Linux
Create Alias for Directory in Linux

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 -l flag.

$ goto -l
Check Available Aliases in Linux
Check Available Aliases in Linux

To expand an alias to its value using the following command.

$ goto -x scripts
$ goto -x march
Expand an Alias Value
Expand an Alias Value

Goto also allows you to unregister an alias, using the -u option.

$ goto -l
$ goto -u march
$ goto -l
Remove Directory Alias in Linux
Remove Directory Alias in Linux

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 -c flag.

$ 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 -h option.

$ 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.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Aaron Kili
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.