Skip to content

Instantly share code, notes, and snippets.

@pdex
Created May 10, 2012 18:43
Show Gist options
  • Save pdex/2655017 to your computer and use it in GitHub Desktop.
Save pdex/2655017 to your computer and use it in GitHub Desktop.
vim session file magic
"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()
#!/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