Created
December 17, 2010 23:38
-
-
Save ashearer/745908 to your computer and use it in GitHub Desktop.
Vim key bindings for Mac to open a Terminal or Finder window pointed at the current file's parent
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
" Add to ~/.vimrc | |
" F5 opens a Terminal window with its current directory set to the current | |
" file's parent. | |
" [The command uses an extra CR at the end to get rid of the "Continue" | |
" prompt, since it will always run over a one-line status bar. :silent doesn't | |
" help when the command itself is too long for the status bar. Putting the | |
" command into a variable before executing may be another way to do it. | |
" Even better: in a function, save sc (showcmd), set nosc, run cmd, restore sc.] | |
map <F5> :!osascript -e 'tell app "Terminal" to activate do script with command "cd " & quoted form of "%:p:h"'<CR><CR> | |
" Shift-F5 opens current buffer's folder in Finder, selecting the current file | |
" if it exists. Works for both directories and files. | |
map <S-F5> :silent execute '![ -f "%:p" ] && open -R "%:p" \|\| open "%:p:h"'<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks :) Was just looking for this!