Dont Use Expansions in Aliases

Don't use expansions within aliases with double quotes ".

  • $(function-expansion)
  • ${VARIABLE_EXPANSION}

Both of these will expand at the time of sourcing the file rather than at the time of execution of this alias. (Hence you will get the working directory when you sourced the files that define these aliases).

# WRONG
alias echo.pwd="echo $(pwd)"
# WRONG
alias echo.pwd="echo $PWD"
# WORKS not recommended
alias echo.pwd='echo $(pwd)'

Instead use shell functions.

Use shell functions when you want to use expansions.

# RECOMMENDED:
echo.pwd(){
  echo $(pwd)
}

To avoid any mistakes of undesired expansions occurring.