voidrice/.local/bin/sd

12 lines
364 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##*"${SHELL##*/}"(}"
PID="${PID#*lf(}"
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"