Search code examples
bashunixaliaspwd

pwd alias causing infinite loop in UNIX (bash)


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?


Solution

  • alias pwd='echo -e ${color1}jarvis: ${color2}you are currently in the ${color3}$(\pwd)${color2} directory, sir.${NC}'
    

    Backslash in \pwd avoids the alias.