Last active
November 2, 2017 15:13
-
-
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
This file contains hidden or 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 | |
# 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