Skip to content

Instantly share code, notes, and snippets.

@maxlath
Created February 26, 2020 18:11
Show Gist options
  • Select an option

  • Save maxlath/724d015d0144880824c3a65482a38e25 to your computer and use it in GitHub Desktop.

Select an option

Save maxlath/724d015d0144880824c3a65482a38e25 to your computer and use it in GitHub Desktop.

Revisions

  1. maxlath created this gist Feb 26, 2020.
    18 changes: 18 additions & 0 deletions .aliases
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    # 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
    }
    3 changes: 3 additions & 0 deletions .favs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    # create an associative array: $favs
    typeset -A favs
    # Elements of that array will be added here after