Skip to content

Instantly share code, notes, and snippets.

@wiedi
Forked from drscream/VIM-Launcher.applescript
Last active August 29, 2015 14:03
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 wiedi/8ac2d8b21b7563041d9d to your computer and use it in GitHub Desktop.
Save wiedi/8ac2d8b21b7563041d9d to your computer and use it in GitHub Desktop.
# finder helper
###############
function pfd() {
osascript 2>/dev/null <<EOF
tell application "Finder"
return POSIX path of (target of window 1 as alias)
end tell
EOF
}
function cdf() {
cd "$(pfd)"
}
on run {input}
set the_path to POSIX path of input
-- run vim command and exit Terminal.app after close
set cmd to "vim " & quoted form of the_path & "; exit"
tell application "System Events" to set terminalIsRunning to exists application process "Terminal"
tell application "Terminal"
-- Open new Tab if Terminal.app is already running
if terminalIsRunning is true then
activate
tell application "System Events" to tell process "Terminal" to keystroke "t" using command down
end if
do script with command cmd in window 1
-- Be sure Terminal.app is active after open vim
activate
end tell
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment