Created
May 10, 2012 18:43
-
-
Save pdex/2655017 to your computer and use it in GitHub Desktop.
vim session file magic
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
"session magic | |
function! SaveSession() | |
"v:this_session is set (by vim) to the last loaded or saved session file | |
if v:this_session != "" | |
echo 'Saving session "' . v:this_session . '"' | |
execute 'mksession! ' . v:this_session | |
endif | |
endfunction | |
au VimLeave * :call SaveSession() |
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 | |
WHICH_VIM=$(which vim) | |
function thisBranch() { git branch | grep '*' | awk '{print $2}'; } | |
function vim() { | |
#if we're inside of a git repo do some magic otherwise do what's expected | |
if git branch &> /dev/null; then | |
mksFile="$(thisBranch).vim" | |
vimOpts="" | |
vimArgs="" | |
if [ -r "$mksFile" ]; then | |
vimOpts="-S $mksFile" | |
else | |
vimArgs="+mks $mksFile" | |
fi | |
$WHICH_VIM $vimOpts $* "$vimArgs" | |
else | |
$WHICH_VIM $* | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment