Skip to content

Instantly share code, notes, and snippets.

@burik666
Created April 7, 2019 07:12
Show Gist options
  • Save burik666/65f53f171f6dc753b394965135cd2058 to your computer and use it in GitHub Desktop.
Save burik666/65f53f171f6dc753b394965135cd2058 to your computer and use it in GitHub Desktop.
Start a new terminal in the same directory (i3wm)
#!/bin/bash
filter="(bash|vi|mc)"
winpid=$(xprop -id $(xdotool getactivewindow) _NET_WM_PID|awk '{print $3}')
if [ -n "$winpid" ]; then
lpid=$(pstree -aApT ${winpid}|grep -E "\\-${filter},[0-9]+" -o|tail -n1|awk -F, '{print $2}')
if [ -n "${lpid}" ]; then
cd $(readlink /proc/${lpid}/cwd)
fi
fi
xterm &
@burik666
Copy link
Author

burik666 commented Apr 7, 2019

i3wm config:

bindsym $mod+Return exec ~/.config/i3/xterm.sh
bindsym $mod+Shift+Return exec xterm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment