pwdfile.zsh 448 B

123456789101112131415161718
  1. # this is for making new terminals cd to the same directory of existing ones
  2. if [[ -x $(which xdotool 2> /dev/null) ]] && [[ -n "$DISPLAY" ]] then
  3. CURRDESKTOP=$(xdotool get_desktop)
  4. PWDFILE="$HOME/.config/bspwm/$CURRDESKTOP.pwd"
  5. function chpwd {
  6. pwd > $PWDFILE
  7. }
  8. ACTIVEWIN=$(xdotool search --desktop $CURRDESKTOP --class $TERMINAL | wc -l)
  9. if [[ $ACTIVEWIN -le 1 ]]; then
  10. chpwd
  11. else
  12. cd "$(cat $PWDFILE)"
  13. fi
  14. fi