Custom .profile / .bashrc config


/ Published in: Bash
Save to your folder(s)

Creates aliases 'save' & 'show' for the subsequent creation of on-the-fly aliases to frequently used directories.

You can save a directory using an abbreviation of your choosing. Eg. 'save foo'




Copy this code and paste it in your HTML
  1. # The following aliases (save & show) are for saving frequently used directories
  2. # You can save a directory using an abbreviation of your choosing. Eg. save ms
  3. # You can subsequently move to one of the saved directories by using cd with
  4. # the abbreviation you choose:
  5. # % cd ms
  6. # (Note that no '$' is necessary with 'cd'.)
  7. #
  8. # You can also use in other operations:
  9. # % cp file1 file2 file3 $acme
  10. # (Here the $ is necessary since (unlike 'cd') the 'cp' command does not
  11. # automatically look for shell variables.)
  12. #
  13. # See: http://www.macosxhints.com/article.php?story=20020716005123797
  14. # See: http://blog.infinitered.com/entries/show/4
  15.  
  16. if [ ! -f ~/.dirs ]; then # if doesn't exist, create it
  17. touch ~/.dirs
  18. fi
  19. alias show='cat ~/.dirs'
  20. save (){
  21. command sed "/!$/d" ~/.dirs > ~/.dirs1; \mv ~/.dirs1 ~/.dirs; echo "$@"=\"`pwd`\" >> ~/.dirs; source ~/.dirs ;
  22. }
  23. source ~/.dirs # Initialization for the above 'save' facility: source the .sdirs file
  24. shopt -s cdable_vars # set the bash option so that no '$' is required when using the above facility

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.