|
|
#1 |
|
MVP
Join Date: Jan 2002
Location: Boston, MA
Posts: 1,489
|
bash alias fiddling
I've always had this set up in my aliases.mine for tcsh (btw, "lc" is another alias to do "ls" in color):
Code:
alias cdd 'cd \!*;echo $cwd; lc -FC' But it does not work perfectly in bash: Code:
alias cdd='cd \!*;echo $cwd; lc -FC' Code:
bash: cd: !*: No such file or directory
__________________
:: 3.4GHz Core i7 iMac 4GB RAM :: Black MacBook SR :: 10.7.2 :: iPhone 4 / iOS 5 :: |
|
|
|
|
|
#2 |
|
League Commissioner
Join Date: Jan 2002
Posts: 5,536
|
bash don't take kindly to csh style ( !* ) args...
in fact, bash aliases don't allow args. bash functions do, tho... the args are: $* expands to $1 $2 $3 ... $@ expands to "$1 $2 $3 ..." try bash functions: Code:
ll () { ls -FlAh --color "$@" | more ; }
ff () { find . -name ${1} -print ; }
zfw () { fgrep -i "$*" /usr/share/dict/web2 | less ; }
|
|
|
|
|
|
#3 |
|
MVP
Join Date: Jan 2002
Location: Boston, MA
Posts: 1,489
|
Thanks...do bash functions also "live" in .bashrc?
__________________
:: 3.4GHz Core i7 iMac 4GB RAM :: Black MacBook SR :: 10.7.2 :: iPhone 4 / iOS 5 :: |
|
|
|
|
|
#4 |
|
League Commissioner
Join Date: Jan 2002
Posts: 5,536
|
this might be closer to your cdd
$ cdd () { cd ${1} ; echo $PWD ; lc -FC ; } but your lc function inside cdd might be a little bit high overhead. i'd explicitly spell out commands in functions. might make debugging them easier. $ cdd () { cd ${1} ; echo $PWD ; ls -FC --color ; } you can list functions with the declare or typeset command note that the final semicolon before the end brace is required. a function is like a full blown script, it can have local variables, control and conditionals in it too. it might behoove you to treat it like a script. bash functions defined in .bashrc will be available in sub-shells and shell-escapes ( like ! in vi ) also note, functions are exec'd in the current process, rather than a fork & exec process. |
|
|
|
![]() |
|
|