Skip to content

Instantly share code, notes, and snippets.

@senthilmpro
Last active August 3, 2024 16:59
Show Gist options
  • Save senthilmpro/7afe88b351a2d308ea59e1328e70ff76 to your computer and use it in GitHub Desktop.
Save senthilmpro/7afe88b351a2d308ea59e1328e70ff76 to your computer and use it in GitHub Desktop.
dir-change.sh
# shorthand to navigate your folders
# add this to ~/.zshrc
# then run "source ~/.zshrc"
# usage "dir music"
# "dir dl"
dir() {
local user=$(whoami)
local folder="$1"
if [ -z "$folder" ]; then
echo "The input string is empty."
elif [[ "$folder" == *"telegram"* ]]; then
cd "/Users/$user/telegram"
elif [[ "$folder" == "dl" ]]; then
cd "/Users/$user/Downloads"
elif [[ "$folder" == "music" ]]; then
cd "/Users/$user/Music"
elif [[ "$folder" == "desktop" ]]; then
cd "/Users/$user/Desktop"
elif [[ "$folder" == "root" ]]; then
cd "/Users/$user"
else
echo "Invalid selection"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment