From c9397f708bbb36a704893b444cc23d92eab2aed1 Mon Sep 17 00:00:00 2001 From: tiyn Date: Sat, 3 Jul 2021 15:40:53 +0000 Subject: [PATCH] samedir: added way to open terminal in same dir modified version of https://github.com/lukesmithxyz/voidrice added. this is already detached from the current terminal, so just append a '&' (like this: 'samedir &') and it opens a new terminal in the same dir. you can then close the terminal that called samedir --- .local/bin/etc/samedir | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100755 .local/bin/etc/samedir diff --git a/.local/bin/etc/samedir b/.local/bin/etc/samedir new file mode 100755 index 0000000..8403c93 --- /dev/null +++ b/.local/bin/etc/samedir @@ -0,0 +1,9 @@ +#!/bin/sh + +# Open a terminal window in the same directory as the currently active window. +# Obtained from https://github.com/lukesmithxyz/voidrice + +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')" +cd "$(readlink /proc/"$PID"/cwd)" || return 1 +setsid "$TERMINAL"