Skip to content

Instantly share code, notes, and snippets.

@schtibe
Last active November 2, 2017 15:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schtibe/0ff5ecfd99882e9767bf6a79ea64ecf2 to your computer and use it in GitHub Desktop.
Save schtibe/0ff5ecfd99882e9767bf6a79ea64ecf2 to your computer and use it in GitHub Desktop.
Spawn a new terminal in the same directory as the current one is in
#!/bin/bash
# Launch a sakura terminal with the same directory as the terminal
# that has the focus
# based on https://faq.i3wm.org/question/150/how-to-launch-a-terminal-from-here/
ID=$(xdpyinfo | grep focus | cut -f4 -d " ")
PID=$(xprop -id $ID | grep PID | awk ' { print $3 }')
SHELL_PID=$(ps -opid= --ppid $PID | tr -d '[:space:]')
CWD="/proc/$SHELL_PID/cwd"
if [[ -e $CWD ]]; then
echo "shell good" >> /tmp/i3shell
sakura -d $(readlink $CWD) &
else
sakura
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment