Tiny Core Linux

General TC => Programming & Scripting - Unofficial => Topic started by: mocore on April 01, 2019, 10:40:42 AM

Title: (tiny) dir bookmarks aka Jumping with symbolic links
Post by: mocore on April 01, 2019, 10:40:42 AM
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: [Select]
# 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
}


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)

Title: Re: (tiny) dir bookmarks aka Jumping with symbolic links
Post by: hiro on April 01, 2019, 11:04:11 AM
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...)
Title: Re: (tiny) dir bookmarks aka Jumping with symbolic links
Post by: andyj on April 01, 2019, 12:06:27 PM
This looks similar to pushd and popd. It would nice to see in busybox shell, but until then bash has it.