WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

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

Offline mocore

  • Hero Member
  • *****
  • Posts: 642
  • ~.~
(tiny) dir bookmarks aka Jumping with symbolic links
« on: April 01, 2019, 01:40:42 PM »
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: 1229
Re: (tiny) dir bookmarks aka Jumping with symbolic links
« Reply #1 on: April 01, 2019, 02:04:11 PM »
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: 1036
Re: (tiny) dir bookmarks aka Jumping with symbolic links
« Reply #2 on: April 01, 2019, 03:06:27 PM »
This looks similar to pushd and popd. It would nice to see in busybox shell, but until then bash has it.