dotfiles-x11.localbinsd
| 1 | #!/bin/sh |
| 2 | |
| 3 | # Open a terminal window in the same directory as the currently active window. |
| 4 | |
| 5 | PID=$(xprop -id "$(xprop -root | xprop -root | sed -n "/_NET_ACTIVE_WINDOW/ s/^.*# // p")" | sed -n "/PID/ s/^.*= // p") |
| 6 | PID="$(pstree -lpA "$PID")" |
| 7 | PID="${PID##*"${SHELL##*/}"(}" |
| 8 | PID="${PID#*lf(}" |
| 9 | PID="${PID%%)*}" |
| 10 | cd "$(readlink /proc/"$PID"/cwd)" || return 1 |
| 11 | "$TERMINAL" |