Last active
August 9, 2016 07:40
-
-
Save gohkhoonhiang/14d95dffe759af17ad951e950edb8ce6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# shortcut to a declared environment variable to a directory | |
# eg. declare myrepo=~/Documents/repo | |
# then do 'to myrepo' will be equivalent to 'cd ~/Documents/repo' | |
function to() { | |
if [ -z "$1" ]; then | |
echo "Empty argument" | |
return | |
fi | |
eval temp_var=\$$1 | |
if [ -z "${temp_var}" ]; then | |
echo "Shortcut not found" | |
return | |
fi | |
cd $temp_var | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment