Files
voidrice/.local/bin/samedir
2022-08-07 10:18:14 +08:00

11 lines
348 B
Bash
Executable File

#!/bin/sh
# Open a terminal window in the same directory as the currently active window.
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%%)*}"
cd "$(readlink /proc/"$PID"/cwd)" || return 1
"$TERMINAL" &