Jump between different directories using shortcuts.
I frequently jump around between very nested directories and it would be nice to have some shortcut to do that. There are already existing tools that do this (much better), but as an exercise I wanted to roll my own.
As we cannot change directories from within the tool itself since it is spawned
as a subprocess that does not have access to our shell, we must integrate it
and pass the directory upwards to our shell to cd
.
The implementation works by generating a file ~/.gotorc
that stores a
shortcut to directory mapping. The tool generates a shell (bash-only right now)
script that is called when goto --init
is run. This is eval
'd in a
bash startup script (~/.bashrc
or ~/.bash_profile
), and creates a function
that reads the directory and cd
's into the directory.
go get github.com/aos/goto
- Add
eval $(goto --init)
in your~/.bashrc
or~/.bash_profile
- Run it and follow the usage instructions:
g
- Custom shortcut keybinding
- Shortcut removal