Skip to content

Instantly share code, notes, and snippets.

@alexanderlperez
Created May 27, 2015 04:10
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 alexanderlperez/85beb769d07147dab1f4 to your computer and use it in GitHub Desktop.
Save alexanderlperez/85beb769d07147dab1f4 to your computer and use it in GitHub Desktop.
dir bookmarks re: bash
#simple bookmarking
function bookmarklist {
i=0
while ((i++)); read -r line; do
echo "$i: $line"
done < /tmp/bookmarks
}
function bookmarkopen() {
line=$(sed -n "$1p" < /tmp/bookmarks)
cd $line
}
function bookmarkpop() {
line=$(sed -n "$1p" < /tmp/bookmarks)
sed -i "" "$1d" /tmp/bookmarks
cd $line
}
function bookmarkdelete() {
sed -i "" "$1d" /tmp/bookmarks
}
# bookmark-related
alias ba="pwd >> /tmp/bookmarks"
alias bl="bookmarklist"
alias bo="bookmarkopen"
alias bp="bookmarkpop"
alias bd="bookmarkdelete"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment