Reputation: 857
I have an alias, dir, which works fine using $(pwd) to show me the current directory I'm in:
alias dir='echo -e ${color1}jarvis: ${color2}you are currently in the ${color3}$(pwd)${color2} directory, sir.${NC}'
I would rather this alias be pwd, or have an identical one for pwd (so i can use dir or pwd to get the exact same response), but I seem to end up in an infinite loop everytime I try alias pwd=dir or
alias pwd='echo -e ${color1}jarvis: ${color2}you are currently in the ${color3}$(pwd)${color2} directory, sir.${NC}'
any ideas?
Upvotes: 1
Views: 381
Reputation: 8718
In bash, the environment variable PWD
is always kept current. pwd
is the shell built-in you shadowed with your alias, and /bin/pwd
is always around in case it's 1984.
Upvotes: 1
Reputation: 198294
alias pwd='echo -e ${color1}jarvis: ${color2}you are currently in the ${color3}$(\pwd)${color2} directory, sir.${NC}'
Backslash in \pwd
avoids the alias.
Upvotes: 3