Not all directories are created equal. When you work on a specific machine, there are directories where you are bound to spend more time than others. The same thing happens on the web, there are pages you will want to visit more often than others. Thankfully, this problem has already been solved with bookmarks. I’m just bringing bookmarks to bash.
For years, I’ve had different systems to allow me to move around faster around my often-used directories. I’ve tried soft links, aliases, and a few other tools. I’m not inventing anything new, I’m just making it more lightweight.
Here’s a screenshot that will explain how “go” works.

You just have to create a flat file named “.gorc” and place it in your home directory. It should contain one path per line, like this:
/home/jonathan/etc
/home/jonathan/media/working
/home/jonathan/lang/ruby/rails
/home/jonathan/lang/erlang/tests/programming_erlang
/home/jonathan/personal/log
/home/jonathan/notes/technical
If you need to add/edit/remove paths, just fire up your favorite text editor. You can also append easily to it with.
echo $PWD >> ~/.gorc
Finally, here’s the source code.
function go() {
if [ ! -f $HOME/.gorc ]; then
echo "$HOME/.gorc does not exist..."
return 1
fi
if [ -n "$1" ]; then
local dest=`cat $HOME/.gorc | sed -n $1p`
else
local places=`cat $HOME/.gorc`
local dest=`pick_from_list $places`
fi
[ -n "$dest" ] && cd $dest
}
function print_list() {
local i item
for item in "$@"; do
((i++))
echo "$i. $item" >&2
done
}
function pick_from_list() {
print_list "$@"
local n
read -p "${PROMPT-">"} " n
((n--)) # zero-based index shift
if ((n < 0 || n >= $#)); then
return 1
fi
shift $n
echo $1
}
Just make sure you “source” the file in your .bashrc and you’re good to go.
This doesn’t seem to work for me in bash when there’s spaces in the directory name. Instead, it treats a space as a sign for a new entry. I’d be willing to bet this could be fixed by changing some quotes somewhere, but I don’t know where.
you’re right…
The problem resides with the fact I’m using plain-Bash and that the mechanisms available to me are limited.
If go was written in a combination of Perl/Python/Ruby and Bash, these problems would not exist … but the runtime would be invoked each time, which would make it noticeably slower.
You could work around this by creating soft links possibly.
[...] a much simpler rewrite of “go” (my directory bookmark miniapp) # pick from directories in $HOME/.gorc and cd into it function go() { if [...]
you should try cdargs, it achieves the same goal and lets you use mnemonics (with tab-completion available) instead of numbers
http://www.skamphausen.de/cgi-bin/ska/CDargs