Krolyxon
Commit 440d4ab

Branches

Refs →

dotfiles-x11.localbinsd

11 lines · 364 B · Bourne Again Shell (bash)

1#!/bin/sh
2
3# Open a terminal window in the same directory as the currently active window.
4
5PID=$(xprop -id "$(xprop -root | xprop -root | sed -n "/_NET_ACTIVE_WINDOW/ s/^.*# // p")" | sed -n "/PID/ s/^.*= // p")
6PID="$(pstree -lpA "$PID")"
7PID="${PID##*"${SHELL##*/}"(}"
8PID="${PID#*lf(}"
9PID="${PID%%)*}"
10cd "$(readlink /proc/"$PID"/cwd)" || return 1
11"$TERMINAL"