Skip to content

Instantly share code, notes, and snippets.

@Psycojoker
Created January 30, 2020 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Psycojoker/fb08b047e4ec7490c232718df822899e to your computer and use it in GitHub Desktop.
Save Psycojoker/fb08b047e4ec7490c232718df822899e to your computer and use it in GitHub Desktop.
Bookmarking system for zsh
# put all _* files into ~/.zsh/completion/
j() {
mkdir -p ~/dotfiles/shell_bookmarks
if [ ! "$1" ]
then
echo "give me an alias as argument"
return
fi
if [ -e ~/dotfiles/shell_bookmarks/"$1" ]
then
cd $(cat ~/dotfiles/shell_bookmarks/$1)
else
echo "not bookmark for alias $1"
fi
}
lb() {
mkdir -p ~/dotfiles/shell_bookmarks
ls ~/dotfiles/shell_bookmarks
}
b() {
mkdir -p ~/dotfiles/shell_bookmarks
if [ ! "$1" ]
then
echo $(pwd) > ~/dotfiles/shell_bookmarks/$(pwd | sed 's#.*/##')
else
echo $(pwd) > ~/dotfiles/shell_bookmarks/$1
fi
}
r() {
mkdir -p ~/dotfiles/shell_bookmarks
if [ ! "$1" ]
then
echo "give me an alias as argument"
return
fi
if [ -e "~/dotfiles/shell_bookmarks/$1" ]
then
rm -f ~/dotfiles/shell_bookmarks/$1
else
echo "not bookmark for alias $1"
fi
}
# compdef b
_arguments "1: :($(pwd | sed 's#.*/##'))"
#compdef j
_arguments "1: :($(ls ~/dotfiles/shell_bookmarks/))"
#compdef r
_arguments "1: :($(ls ~/dotfiles/shell_bookmarks/))"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment