summaryrefslogtreecommitdiffstats
path: root/.local/bin/samedir
diff options
context:
space:
mode:
authorkrisdoodle45 <86745210+krisdoodle45@users.noreply.github.com>2022-02-17 18:13:14 +0100
committerGitHub <noreply@github.com>2022-02-17 18:13:14 +0100
commitc16d6fd3b04670b2ae1315cfbc5dd6b53d44d0c5 (patch)
tree21b640553e5efd77b05cb63dbb30496867ce224d /.local/bin/samedir
parent9ad912fe4eaf8c1b9c844780829aaea693c1e6de (diff)
parent82b70e3a8e3aed45998c38024e8c3e16f9680cff (diff)
downloadeibhear-c16d6fd3b04670b2ae1315cfbc5dd6b53d44d0c5.tar.gz
eibhear-c16d6fd3b04670b2ae1315cfbc5dd6b53d44d0c5.tar.zst
eibhear-c16d6fd3b04670b2ae1315cfbc5dd6b53d44d0c5.zip
Merge branch 'LukeSmithxyz:master' into patch-4
Diffstat (limited to '.local/bin/samedir')
-rwxr-xr-x.local/bin/samedir6
1 files changed, 4 insertions, 2 deletions
diff --git a/.local/bin/samedir b/.local/bin/samedir
index 73facfd..0a19707 100755
--- a/.local/bin/samedir
+++ b/.local/bin/samedir
@@ -2,7 +2,9 @@
# Open a terminal window in the same directory as the currently active window.
-PID=$(xprop -id "$(xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}')" | grep -m 1 PID | cut -d " " -f 3)
-PID="$(pstree -lpA "$PID" | tail -n 1 | awk -F'---' '{print $NF}' | sed -re 's/[^0-9]//g')"
+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%)}"
cd "$(readlink /proc/"$PID"/cwd)" || return 1
"$TERMINAL"