Skip to content

Instantly share code, notes, and snippets.

@tastycode
Created January 13, 2012 03:56
Show Gist options
  • Save tastycode/1604608 to your computer and use it in GitHub Desktop.
Save tastycode/1604608 to your computer and use it in GitHub Desktop.
Vimcopy
-- with shell execution from http://neverblog.net/run-unix-commands-in-an-applescript/
tell application "System Events"
set front_app to item 1 of (get name of processes whose frontmost is true)
end tell
tell application "Terminal"
-- take the clipboard contents, pass through tr to remove odd newlines, write to vimcopy.txt, open vimcopy with vim,
-- the once closed, write vimcopy.txt contents to clipboard and exit
set vim_tab to do script "pbpaste | tr '\\015\\032' '\\n' > ~/.vimcopy.txt && vim ~/.vimcopy.txt && cat ~/.vimcopy.txt | pbcopy && exit"
activate
delay 0.25
repeat while busy of vim_tab is true
delay 0.25
end repeat
tell application "System Events"
keystroke "q" using {command down}
end tell
end tell
tell application front_app
activate
delay 0.25
tell application "System Events"
keystroke "v" using {command down}
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment