2020-02-08 23:43:37 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2020-03-08 22:23:38 +00:00
|
|
|
# Open a terminal window in the same directory as the currently active window.
|
|
|
|
|
2022-11-16 16:04:26 +00:00
|
|
|
PID=$(xprop -id "$(xprop -root | sed -n "/_NET_ACTIVE_WINDOW/ s/^.*# // p")" | sed -n "/PID/ s/^.*= // p")
|
|
|
|
PID=$(pstree -lpATna "$PID" | grep -v '\-\(lf,[0-9]\+ -server\|(st-urlhandler,[0-9]\+)\|xclip,[0-9]\+\)' | sed '$s/.*,\([0-9]\+\).*/\1/;t;d')
|
|
|
|
cwd=$(readlink /proc/"$PID"/cwd)
|
|
|
|
[ "$PWD" != "$cwd" ] && [ -d "$cwd" ] && { cd "$cwd" || exit 1; }
|
2018-12-09 20:26:40 +00:00
|
|
|
"$TERMINAL"
|