Last active
November 15, 2017 21:12
-
-
Save jackinloadup/c46aa8751925bc8845524602ae544f56 to your computer and use it in GitHub Desktop.
open-here - for use with uxrvt and x11. will open a terminal in the same directory as the terminal you have focused
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Get the focused window ID | |
ID=$(xdpyinfo | grep focus | cut -f4 -d " ") | |
# Get the SHELL id | |
PID=$(xprop -id "$ID" | grep -m 1 PID | cut -d " " -f 3) | |
# get the TERM id that is running the SHELL | |
TERM_ID=$(pgrep -P "$PID") | |
# if there is a current working directory navigate to it | |
if [ -e "/proc/$TERM_ID/cwd" ]; then | |
urxvt -cd "$(readlink "/proc/${TERM_ID}/cwd")" & | |
else | |
urxvt | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment