Skip to content

Instantly share code, notes, and snippets.

@tobyS
Created August 28, 2015 13:36
Show Gist options
  • Save tobyS/a8631772582924db4668 to your computer and use it in GitHub Desktop.
Save tobyS/a8631772582924db4668 to your computer and use it in GitHub Desktop.
Re-attach to an existing VIM session in a new tab
#!/bin/bash
# alias vim="vimmux"
export TERM="xterm-256color"
if tmux has-session -t vim
then
if [ "$#" != "1" ]
then
echo "There is another VIM session in TMUX and we cannot open tabs with multiple parameters. Do manually!"
exit 1;
fi
file=$(readlink -f $1)
tmux send-keys -t vim:vim ":tabe $file" C-m
tmux attach-session -t vim
exit 1;
fi
tmux -2 new-session -s vim -n vim "vim $@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment