summaryrefslogtreecommitdiffstats
path: root/.local/bin/samedir
diff options
context:
space:
mode:
authorLuke Smith <luke@lukesmith.xyz>2020-03-08 18:23:38 -0400
committerLuke Smith <luke@lukesmith.xyz>2020-03-08 18:23:38 -0400
commit2acedd3517ed52e1861e21d01945d8b16dfc163e (patch)
tree5733e22aebdcc8df42afe7ed61f3ae0fdd2a5448 /.local/bin/samedir
parentb085acedb0a2beb64ffd01dfb664fc8be7589795 (diff)
downloadeibhear-2acedd3517ed52e1861e21d01945d8b16dfc163e.tar.gz
eibhear-2acedd3517ed52e1861e21d01945d8b16dfc163e.tar.zst
eibhear-2acedd3517ed52e1861e21d01945d8b16dfc163e.zip
samedir tweak
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 740dcfc..73facfd 100755
--- a/.local/bin/samedir
+++ b/.local/bin/samedir
@@ -1,6 +1,8 @@
#!/bin/sh
+# 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=$(echo "$(pstree -lpA "$PID" | tail -n 1)" | awk -F'---' '{print $NF}' | sed -re 's/[^0-9]//g')
-cd "$(readlink /proc/"$PID"/cwd)"
+PID="$(pstree -lpA "$PID" | tail -n 1 | awk -F'---' '{print $NF}' | sed -re 's/[^0-9]//g')"
+cd "$(readlink /proc/"$PID"/cwd)" || return 1
"$TERMINAL"