Skip to content

Instantly share code, notes, and snippets.

@tschaub
Created August 30, 2011 05:43
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 tschaub/1180263 to your computer and use it in GitHub Desktop.
Save tschaub/1180263 to your computer and use it in GitHub Desktop.
Automator Workflow for Slowly Pasting in Terminal
on run {input, parameters}
set clip_text to (the clipboard as text)
set clip_paragraphs to paragraphs of clip_text
if (count of clip_paragraphs) > 0 then
set line_text to item 1 of clip_paragraphs
repeat with n from 1 to count of line_text
set next_char to character n of line_text
tell application "Terminal"
activate
tell window 1
tell application "System Events" to keystroke next_char
end tell
end tell
delay 0.02 + (random number 0.1)
end repeat
tell application "Terminal"
activate
tell window 1
tell application "System Events" to keystroke return
end tell
end tell
set num_lines to count of clip_paragraphs
if num_lines > 1 then
set remaining_lines to items 2 thru num_lines of clip_paragraphs
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to return
set output to remaining_lines as Unicode text
set AppleScript's text item delimiters to tid
set the clipboard to output
else
set the clipboard to ""
end if
end if
return input
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment