WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: (tiny) dir bookmarks aka Jumping with symbolic links  (Read 767 times)

Offline mocore

  • Full Member
  • ***
  • Posts: 238
(tiny) dir bookmarks aka Jumping with symbolic links
« 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)


Offline hiro

  • Hero Member
  • *****
  • Posts: 1117
Re: (tiny) dir bookmarks aka Jumping with symbolic links
« Reply #1 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...)

Offline andyj

  • Hero Member
  • *****
  • Posts: 748
Re: (tiny) dir bookmarks aka Jumping with symbolic links
« Reply #2 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.