Simple Bash utility for navigating quickly to set directories.
$ hop --help
Usage: hop [-i] DIRNAME
Hops to directories defined in /home/username/.hopdirs by only using their name.
Options:
-i Ignore case when searching through directory names.
$ hop Teal-Album
The script will search at ~/.hopdirs
for directories named Teal-Album
. If found, it will cd
there.
.hopdirs
is a list of directory paths separated by new lines.
As a manually maintained list of bookmarks:
# .hopdirs
/home/username/Projects/myproject
/home/username/Music/Weezer/Teal-Album
NOTE: Lines that start with
#
are ignored.
Or generated with find
to simplify navigation in a nested hell of directories:
- university/
- courses/
- 2018-19/
- algorithms/
- databases/
- comparch/
- 2017-18/
- dsp/
- discrete-math/
- calculus-ii/
- ...
- 2018-19/
- courses/
$ find /path/to/university -mindepth 3 maxdepth 3 -type d -print >> ~/.hopdirs
# Hop hop hop
$ hop calculus-ii
Just source hop.sh
:
$ . hop.sh
You can also add it to your .bashrc
and then have it available every time you launch your shell.
# .bashrc
# ...rest of the file
if [ -f /path/to/hop.sh ]; then
. /path/to/hop.sh
fi
hop
can be customized through the following environment variables.
HOPDIRS_FILE
:
Path to the hopdirs file. Default is~/.hopdirs
.HOP_ICASE
:
Set to1
to force case-insensitive lookups and autocompletions. Default is0
.
$ export HOPDIRS_FILE=/path/to/hopdirs
$ export HOP_ICASE=1
$ hop teal-album