Skip to content

Instantly share code, notes, and snippets.

@jackinloadup
Last active November 15, 2017 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jackinloadup/c46aa8751925bc8845524602ae544f56 to your computer and use it in GitHub Desktop.
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
#!/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