term-open-same-dir.sh 359 B

1234567891011121314
  1. #!/bin/bash
  2. ID=$(xdpyinfo | grep focus | cut -f4 -d " ")
  3. echo $ID
  4. PID=$(($(xprop -id $ID | grep -m 1 PID | cut -d " " -f 3)+7))
  5. echo $PID
  6. if [ -e "/proc/$PID/cwd" ]
  7. then
  8. echo "right one"
  9. echo $(readlink /proc/$PID/cwd)
  10. alacritty --working-directory $(readlink /proc/$PID/cwd) --command /usr/bin/zsh &
  11. else
  12. alacritty --command /usr/bin/zsh
  13. fi