Skip to content

Instantly share code, notes, and snippets.

@maxlath
Created February 26, 2020 18:11
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 maxlath/724d015d0144880824c3a65482a38e25 to your computer and use it in GitHub Desktop.
Save maxlath/724d015d0144880824c3a65482a38e25 to your computer and use it in GitHub Desktop.
# Initialize the array of favs
source ~/.favs
# Create an alias for each of the favs
for key in $favs
do
directory="$favs[$key]"
alias $key="cd $directory"
done
# Set a fav command to define new fav directories
fav(){
dir_shortkey=$1
# Associate the current directory to a shortkey
echo "favs[${dir_shortkey}]=${PWD}\n" >> ~/.favs
# and reload the favs
source ~/.favs
}
# create an associative array: $favs
typeset -A favs
# Elements of that array will be added here after
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment