-
-
Save arcusfelis/9761788 to your computer and use it in GitHub Desktop.
Vim integration with tmux
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 | |
filename="$1" | |
basename="$(basename $1)" | |
curpath="$(pwd)" | |
cd "$(dirname $filename)" | |
pid="$(vim -r 2>&1 | fgrep "$basename.sw" -A 5 | grep 'still running' | sed 's/[^0-9]//g')" | |
cd "$curpath" | |
if [ -n "$pid" ]; then | |
tty="$(ps -p $pid -o tty h)" | |
window="$(tmux list-panes -s -F '#{window_id} #{pane_tty}' | grep "$tty" | cut -d ' ' -f1)" | |
tmux select-window -t "$window" | |
else | |
old_window_name="$(tmux list-panes -F '#{window_name}')" | |
tmux rename-window "_$basename" | |
vim "$filename" | |
tmux rename-window "$old_window_name" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment