Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/iridakos/goto
Alias and navigate to directories with tab completion in Linux
https://github.com/iridakos/goto
aliases bash directories linux productivity registered-aliases utility zsh
Last synced: 4 days ago
JSON representation
Alias and navigate to directories with tab completion in Linux
- Host: GitHub
- URL: https://github.com/iridakos/goto
- Owner: iridakos
- License: mit
- Created: 2018-03-04T18:27:09.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-07-26T16:57:39.000Z (6 months ago)
- Last Synced: 2025-01-02T20:11:58.579Z (11 days ago)
- Topics: aliases, bash, directories, linux, productivity, registered-aliases, utility, zsh
- Language: Shell
- Homepage: https://iridakos.com/programming/2019/04/10/shell-navigation-with-autocomplete
- Size: 3.13 MB
- Stars: 879
- Watchers: 22
- Forks: 64
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- my-awesome-starred - iridakos/goto - Alias and navigate to directories with tab completion in Linux (Shell)
- awesome-starred - iridakos/goto - Alias and navigate to directories with tab completion in Linux (bash)
- jimsghstars - iridakos/goto - Alias and navigate to directories with tab completion in Linux (Shell)
README
# goto
A shell utility allowing users to navigate to aliased directories supporting auto-completion :feet:
![Generic badge](https://img.shields.io/badge/version-2.0.0-green.svg)
## How does it work?
User registers directory aliases, for example:
```bash
goto -r dev /home/iridakos/development
```
and then `cd`s to that directory with:
```bash
goto dev
```![goto demo gif](https://github.com/iridakos/goto/raw/master/doc/goto.gif)
## goto completion
`goto` 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:
```bash
$ goto
bc /etc/bash_completion.d
dev /home/iridakos/development
rubies /home/iridakos/.rvm/rubies
```## Installation
### Via script
Clone the repository and run the install script as super user or root:
```bash
git clone https://github.com/iridakos/goto.git
cd goto
sudo ./install
```### Manually
Copy 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:
```bash
source ~/goto.sh
```### macOS - Homebrew
A formula named `goto` is available for the bash shell in macOS.
```bash
brew install goto
```### Add colored output
```bash
echo -e "\$include /etc/inputrc\nset colored-completion-prefix on" >> ~/.inputrc
```**Note:**
- you need to restart your shell after installation
- you need to have the bash completion feature enabled for bash in macOS (see this [issue](https://github.com/iridakos/goto/issues/36)):
- you can install it with `brew install bash-completion` in case you don't have it already## Usage
* [Change to an aliased directory](#change-to-an-aliased-directory)
* [Register an alias](#register-an-alias)
* [Unregister an alias](#unregister-an-alias)
* [List aliases](#list-aliases)
* [Expand an alias](#expand-an-alias)
* [Cleanup](#cleanup)
* [Help](#help)
* [Version](#version)
* [Extras](#extras)
* [Push before changing directories](#push-before-changing-directories)
* [Revert to a pushed directory](#revert-to-a-pushed-directory)
* [Troubleshooting](#troubleshooting)
* [Updating from 1.x to 2.x](#updating-from-1x-to-2x)
* [zsh](#zsh)
* [command not found compdef](#command-not-found-compdef)### Change to an aliased directory
To change to an aliased directory, type:
```bash
goto
```#### Example:
```bash
goto dev
```### Register an alias
To register a directory alias, type:
```bash
goto -r
```
or
```bash
goto --register
```#### Example:
```bash
goto -r blog /mnt/external/projects/html/blog
```
or
```bash
goto --register blog /mnt/external/projects/html/blog
```#### Notes
* `goto` **expands** the directories hence you can easily alias your current directory with:
```bash
goto -r last_release .
```
and it will automatically be aliased to the whole path.
* Pressing the `tab` key after the alias name, you have the default directory suggestions by the shell.### Unregister an alias
To unregister an alias, use:
```bash
goto -u
```
or
```bash
goto --unregister
```
#### Example
```
goto -u last_release
```
or
```
goto --unregister last_release
```#### Notes
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.
### List aliases
To get the list of your currently registered aliases, use:
```bash
goto -l
```
or
```bash
goto --list
```### Expand an alias
To expand an alias to its value, use:
```bash
goto -x
```
or
```bash
goto --expand
```#### Example
```bash
goto -x last_release
```
or
```bash
goto --expand last_release
```### Cleanup
To cleanup the aliases from directories that are no longer accessible in your filesystem, use:
```bash
goto -c
```
or
```bash
goto --cleanup
```### Help
To view the tool's help information, use:
```bash
goto -h
```
or
```bash
goto --help
```### Version
To view the tool's version, use:
```bash
goto -v
```
or
```bash
goto --version
```## Extras
### Push before changing directories
To first push the current directory onto the directory stack before changing directories, type:
```bash
goto -p
```
or
```bash
goto --push
```### Revert to a pushed directory
To return to a pushed directory, type:
```bash
goto -o
```
or
```bash
goto --pop
```#### Notes
This command is equivalent to `popd`, but within the `goto` command.
## Troubleshooting
### Updating from 1.x to 2.x
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 `.`*
### zsh
#### command not found: compdef
In case you get such an error, you need to load the `bashcompinit`. Append this to your `.zshrc` file:
```bash
autoload bashcompinit
bashcompinit
```## TODO
* ~~Test on macOS~~ extensively
* Write [tests](https://github.com/iridakos/goto/issues/2)## Contributing
1. Fork it ( https://github.com/iridakos/goto/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Make sure that the script does not have errors or warning on [ShellCheck](https://www.shellcheck.net/)
6. Create a new Pull Request## License
This tool is open source under the [MIT License](https://opensource.org/licenses/MIT) terms.
[[Back To Top]](#goto)