General TC > Programming & Scripting - Unofficial
(tiny) dir bookmarks aka Jumping with symbolic links
(1/1)
mocore:
Just happened to find this https://www.datascienceworkshops.com/blog/quickly-navigate-your-filesystem-from-the-command-line/
while searching for that and the other ...
seams to fit the tiny core MO
..so hear's the code:
--- Code: ---# source @ https://www.datascienceworkshops.com/blog/quickly-navigate-your-filesystem-from-the-command-line/
export MARKPATH=$HOME/.marks
function jump {
cd -P "$MARKPATH/$1" 2>/dev/null || echo "No such mark: $1"
}
function mark {
mkdir -p "$MARKPATH"; ln -s "$(pwd)" "$MARKPATH/$1"
}
function unmark {
rm -i "$MARKPATH/$1"
}
function marks {
ls -l "$MARKPATH" | sed 's/ / /g' | cut -d' ' -f9- | sed 's/ -/\t-/g' && echo
}
--- End code ---
eg
--- Quote ---$ cd ~/some/very/deep/often-used/directory
$ mark deep # bookmark current directory
$ cd ~/
jump deep # jump to bokmarked directory
marks # list bookmarks
deep -> /home/johndoe/some/very/deep/often-used/directory
foo -> /usr/bin/foo/bar
unmark deep # remove bookmark (i.e., the symbolic link)
--- End quote ---
hiro:
i approve of the usage of small scripts like this to make common tasks easier.
myself i use a small script that is called tohd, that takes a directory from $HOME, moves it from RAMFS into my storage, then adds a symbolic link in the $HOME and triggers a background backup.
(or is it called tmpfs? this stuff has changed in the past...)
andyj:
This looks similar to pushd and popd. It would nice to see in busybox shell, but until then bash has it.
Navigation
[0] Message Index
Go to full version