Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'version for bash' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
version for bash
Authored by: hayne on Oct 12, '04 01:11:37AM
Since the default shell for new accounts in Panther is 'bash' instead of 'tcsh', I thought it might be useful to show how to translate the above C-shell aliases for use in bash. Here is what I have in my ~/.profile file:

# The following aliases (save & show) are for saving frequently used directories
# You can save a directory using an abbreviation of your choosing. Eg. save ms
# You can subsequently move to one of the saved directories by using cd with
# the abbreviation you chose. Eg. cd ms  (Note that no '$' is necessary.)
alias sdirs='source ~/.dirs' 
alias show='cat ~/.dirs'
save () { command sed "/!$/d" ~/.dirs > ~/.dirs1; \mv ~/.dirs1 ~/.dirs; echo "$@
"=\"`pwd`\" >> ~/.dirs; source ~/.dirs ; }

# Initialization for the above 'save' facility:
# source the .sdirs file:
sdirs
# set the bash option so that no '$' is required when using the above facility
shopt -s cdable_vars


[ Reply to This | # ]
Re: version for bash
Authored by: hayne on Apr 07, '06 08:05:12AM
The above 'save' function should be revised to use $@ instead of !$ - i.e. it should be:

save () { /usr/bin/sed "/$@/d" ~/.dirs > ~/.dirs1; \mv ~/.dirs1 ~/.dirs; echo "$@"=\"`pwd`\" >> ~/.dirs; source ~/.dirs ; }


[ Reply to This | # ]