From 18dad565fa03801f12bc010324e578d32a4883e0 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Wed, 20 Oct 2021 10:50:13 -0400 Subject: [PATCH] inconsequential efficiency --- .local/bin/samedir | 6 ++++-- 1 file 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"