diff options
| author | Luke Smith <luke@lukesmith.xyz> | 2023-01-15 08:23:54 -0500 |
|---|---|---|
| committer | Luke Smith <luke@lukesmith.xyz> | 2023-01-15 08:23:54 -0500 |
| commit | 9385a569fe356db706ed268a87e77cfa760d58dd (patch) | |
| tree | 2c8d3b6e3e72f6dd2e211a5cf380baf301d2f545 /.local/bin/sd | |
| parent | 5c52bd63394aafbb93b6713b74c148e5a4ec17c7 (diff) | |
| parent | 5c262da7c39fb0b3cd52acca36f45d4e7c629d37 (diff) | |
| download | eibhear-9385a569fe356db706ed268a87e77cfa760d58dd.tar.gz eibhear-9385a569fe356db706ed268a87e77cfa760d58dd.tar.zst eibhear-9385a569fe356db706ed268a87e77cfa760d58dd.zip | |
Merge branch 'master' of github.com:LukeSmithxyz/voidrice
Diffstat (limited to '.local/bin/sd')
| -rwxr-xr-x | .local/bin/sd | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/.local/bin/sd b/.local/bin/sd index 7e09bf6..8047d33 100755 --- a/.local/bin/sd +++ b/.local/bin/sd @@ -2,10 +2,8 @@ # 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#*lf(}" -PID="${PID%%)*}" -cd "$(readlink /proc/"$PID"/cwd)" || return 1 +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; } "$TERMINAL" |
