Skip to content

Instantly share code, notes, and snippets.

@rjungemann
Created September 17, 2012 01:47
Show Gist options
  • Save rjungemann/3735143 to your computer and use it in GitHub Desktop.
Save rjungemann/3735143 to your computer and use it in GitHub Desktop.
Text to and from system clipboard to tmux using AppleScript
-- putting current selection in clipboard
-- set tmux path
set tmux_path to "/usr/local/bin/tmux"
-- copy selected text to clipboard
tell application "System Events" to keystroke "c" using {command down}
delay 0.1 -- so copy can take place
set selected_text to (the clipboard as text)
-- give tmux the text from the clipboard
do shell script "pbpaste | " & tmux_path & " load-buffer -"
-- paste from tmux
-- set tmux path
set tmux_path to "/usr/local/bin/tmux"
do shell script tmux_path & " save-buffer - | pbcopy"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment