A shell utility allowing users to navigate to aliased directories supporting auto-completion 🐾
User registers directory aliases, for example:
goto -r dev /home/iridakos/developmentand then cds to that directory with:
goto devgoto comes with a nice auto-completion script so that whenever you press the tab key after the goto command, bash or zsh prompts with suggestions of the available aliases:
$ goto <tab>
bc /etc/bash_completion.d                     
dev /home/iridakos/development
rubies /home/iridakos/.rvm/rubiesClone the repository and run the install script as super user or root:
git clone https://github.com/iridakos/goto.git
cd goto
sudo ./installCopy the file goto.sh somewhere in your filesystem and add a line in your .zshrc or .bashrc to source it.
For example, if you placed the file in your home folder, all you have to do is add the following line to your .zshrc or .bashrc file:
source ~/goto.shA formula named goto is available for the bash shell in macOS.
brew install gotoecho -e "\$include /etc/inputrc\nset colored-completion-prefix on" >> ~/.inputrcNote:
- you need to restart your shell after installation
- you need to have the bash completion feature enabled for bash in macOS (see this issue):
- you can install it with brew install bash-completionin case you don't have it already
 
- you can install it with 
- Change to an aliased directory
- Register an alias
- Unregister an alias
- List aliases
- Expand an alias
- Cleanup
- Help
- Version
- Extras
- Troubleshooting
To change to an aliased directory, type:
goto <alias>goto devTo register a directory alias, type:
goto -r <alias> <directory>or
goto --register <alias> <directory>goto -r blog /mnt/external/projects/html/blogor
goto --register blog /mnt/external/projects/html/blog- gotoexpands the directories hence you can easily alias your current directory with:
goto -r last_release .and it will automatically be aliased to the whole path.
- Pressing the tabkey after the alias name, you have the default directory suggestions by the shell.
To unregister an alias, use:
goto -u <alias>or
goto --unregister <alias>goto -u last_release
or
goto --unregister last_release
Pressing the tab key after the command (-u or --unregister), the completion script will prompt you with the list of registered aliases for your convenience.
To get the list of your currently registered aliases, use:
goto -lor
goto --listTo expand an alias to its value, use:
goto -x <alias>or
goto --expand <alias>goto -x last_releaseor
goto --expand last_releaseTo cleanup the aliases from directories that are no longer accessible in your filesystem, use:
goto -cor
goto --cleanupTo view the tool's help information, use:
goto -hor
goto --helpTo view the tool's version, use:
goto -vor
goto --versionTo first push the current directory onto the directory stack before changing directories, type:
goto -p <alias>or
goto --push <alias>To return to a pushed directory, type:
goto -oor
goto --popThis command is equivalent to popd, but within the goto command.
From version 2.x and after, the goto DB file is located in the $XDG_CONFIG_HOME or in the ~/.config directory under the name goto.
If you updated from version 1.x to 2.x or newer, you need to move this file which was previously located at ~/.goto.
Note that the new file is not hidden, it does not start with a dot .
In case you get such an error, you need to load the bashcompinit. Append this to your .zshrc file:
autoload bashcompinit
bashcompinit- Test on macOSextensively
- Write tests
- Fork it ( https://github.com/iridakos/goto/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Make sure that the script does not have errors or warning on ShellCheck
- Create a new Pull Request
This tool is open source under the MIT License terms.
