Hey! I'm the writer of these tools and was kind of surprised to run into it here, since I have not posted about this before — the submitter must have been an adventurous PyPI visitor ;)<p>This particular tool was mostly written to replace all the ad-hoc aliases and symlinks with something that could be easily maintained and brought to other commands (eg. cdbm, lsbm, mvbm, cpbm, etc.). To speed things up some more there's also tab completion and prefix matching, which is pretty convenient IMO.
Instead of needing to have bookmark-aware commands in the first place ("commands that are available are and bookmark-aware: lsbm, cpbm, mvbm, mkbm, ...") , it would probably be better to use backtick:<p><pre><code> cd `bm shortcutname`
</code></pre>
Forking loads of common utilities is going to add lots of superfluous complexity. Of course, at that point you could replace the whole bm suite with shell aliases or a script that contains<p><pre><code> #!/bin/sh
# find relevant line by key, get the second field
grep "$1 " ~/.bms | cut -d " " -f 2
</code></pre>
. Put that in your path, chmod u+x bm, and there you go. In this case, the bookmarks file is hardcoded to ~/.bms and you edit it by hand, but that's probably good enough. If you want to add from the shell, here's bm-add:<p><pre><code> #!/bin/sh
echo $1 $2 >> ~/.bms
</code></pre>
Put it in your path, chmod u+x bm-add, good to go.<p>If you'd rather have the bookmark file separated by tabs, just remove the -d " " from bm, change the grep to "$1\\t", and change bm-add to echo $1\\t$2 >> ~/.bms. Simple.<p>For an excellent intro on how to work with Unix's strengths, read _The Unix Programming Environment_ by Kernighan and Pike.
I have these functions in my .bashrc<p>addpi()
{
echo "cd `pwd` $1" >> ~/.pi;
echo
}<p>pi()
{
`cat ~/.pi | grep $1`;
}<p>Usage: when you are in a dir that you want to bookmark say
addpi <name><p>when you want to return to that dir from anywhere say
pi <name><p>Ofcourse you need some kind of resolution if you have 2 matches in the grep, but it works for me.
I've done this for years in my DOS sessions. A small program called qcd ("quick cd") reads the current working directory and writes a corresponding "cd" command to a batch file in c:\windows:<p>------------------<p>c:\foo\bar\bat>qcd 1<p>(creates file called c:\windows\1.bat containing "cd \foo\bar\bat")<p>c:\foo\bar\bat>cd \frotz\ozmoo<p>c:\frotz\ozmoo>1<p>c:\foo\bar\bat>