1
0
mirror of https://github.com/tiyn/dotfiles.git synced 2025-03-19 10:17:44 +01:00
tiyn c9397f708b 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
2021-07-03 15:40:53 +00:00

10 lines
423 B
Bash
Executable File

#!/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"