Skip to content

Instantly share code, notes, and snippets.

@darcyparker
Forked from scrooloose/startshell_mapping.vim
Created December 7, 2011 02:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darcyparker/1441083 to your computer and use it in GitHub Desktop.
Save darcyparker/1441083 to your computer and use it in GitHub Desktop.
"guard against sourcing the script twice
if exists("g:loaded_nerdtree_start_shell_mapping")
finish
endif
let g:loaded_nerdtree_start_shell_mapping = 1
"bind 'S' to NERDTreeStartShell()
call NERDTreeAddKeyMap({
\ 'key': 'S',
\ 'callback': 'NERDTreeStartShell',
\ 'quickhelpText': 'start a :ConqueTerm in this dir' })
"change to the dir of the current node and start a :shell
function! NERDTreeStartShell()
"grab the currently selected dir node (returns
"the parent dir if a file is selected)
let n = g:NERDTreeDirNode.GetSelected()
"save the cwd so we can restore it after the :shell exits
let oldCWD = getcwd()
try
":lcd to to the selected dir and :shell out
exec 'lcd ' . n.path.str({'format': 'Cd'})
redraw!
let my_terminal = conque_term#open(&shell, ['botright new', 'resize 20'])
"make sure we restore the cwd to its original state
finally
exec 'lcd ' . oldCWD
endtry
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment