Files
scripts/goto
T
2023-06-13 19:41:00 -06:00

42 lines
937 B
Bash
Executable File

#!/bin/zsh
# Dependencies:
# quaxlyqueen/scripts/mark
BOOKMARKS_FILE=~/.bookmarks
# Catch any invalid input.
if [[ $# -eq 0 || $# -gt 1 ]]; then
echo "\nImproper usage. Try:"
echo "\ngoto [keyword]"
echo " goto downloads"
echo " goto school"
echo " goto portfolio"
echo " goto -h"
echo " goto --help"
# Display help.
elif [[ $1 == "-h" || $1 == "--help" ]]; then
echo "\nImproper usage. Try:"
echo "\ngoto [keyword]"
echo " goto downloads"
echo " goto school"
echo " goto portfolio"
echo " goto -h"
echo " goto --help"
else
# Locate the bookmark.
if [ $(grep -c "$1" $BOOKMARKS_FILE) -gt 0 ]; then
# Go to the bookmark
cd $(grep "$1" $BOOKMARKS_FILE | head -n 1)
# List bookmarks if bookmark was not found.
else
echo "Bookmark not found. Available bookmarks:"
mark -ls
fi
fi