Hook function when the working directory is changed

chpwd is called when the current working directory is changed. Array variable chpwd_functions can be used to declare additional hook functions.

Examples

Echo new working directory to STDERR and STDOUT
1
2
3
4
5
6
chpwd() { echo "Working dir (STDOUT): $PWD"; }
  
chpwd_stderr() { echo "Working dir (STDERR): $PWD" >&2; }
chpwd_functions=(chpwd_stderr)
  
cd ~
Output:
1
2
Working dir (STDOUT): /home/user
Working dir (STDERR): /home/user
BashSupport Pro is a Zsh IDE with support for chpwdtry it now!
© 2020–2024 Joachim Ansorg
Imprint
Privacy Policy
Legal