voidrice/.local/bin/samedir

11 lines
330 B
Text
Raw Normal View History

#!/bin/sh
2020-03-08 22:23:38 +00:00
# Open a terminal window in the same directory as the currently active window.
2021-10-20 14:50:13 +00:00
PID=$(xprop -id "$(xprop -root | xprop -root | sed -n "/_NET_ACTIVE_WINDOW/ s/^.*# // p")" | sed -n "/PID/ s/^.*= // p")
PID="$(pstree -lpA "$PID")"
PID="${PID##*(}"
PID="${PID%)}"
2020-03-08 22:23:38 +00:00
cd "$(readlink /proc/"$PID"/cwd)" || return 1
2018-12-09 20:26:40 +00:00
"$TERMINAL"