Re:Nice commandline directory bookmarker. (Saves you typing ...
by silentbicycle on Friday October 02, 2009 @01:55PM
(#857571)
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:
cd `bm shortcutname`
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
#!/bin/sh
# find relevant line by key, get the second field
grep "$1 " ~/.bms | cut -d " " -f 2
. 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:
#!/bin/sh
echo $1 $2 >> ~/.bms
Put it in your path, chmod u+x bm-add, good to go.
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.
For an excellent intro on how to work with Unix's strengths, read _The Unix Programming Environment_ by Kernighan and Pike.
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.
For an excellent intro on how to work with Unix's strengths, read _The Unix Programming Environment_ by Kernighan and Pike.