Does any of this work?
Option 1
- Copy text in Sublime Text
- Go to Xquartx type pbpaste & hit return
Sublime text copies into the Mac pasteboard.
pbpaste will insert that at the Xquartz Terminal.
If you want to execute the content of the clipboard wrap it in back ticks or $() e.g.
`pbpaste`
$(pbpaste)
I suggest making an alias in your bash_profile to allow you to do this quickly.
It isn't Applescript & it isn't automatic but I can't see how Apple script can solve it unless there is a scriptable X11 interface, GUI scripting may work but it just drives me crazy - good luck with that 🙂
Obviously pbpaste is a local command so I'm assuming you are running a local X11 session, otherwise all bets are off.
Option 2
Ask Sublime Text to 'shove some stuff into a file?!'…
Wrap in backticks to cause execution.
My point here is that Sublime Text has some kind of 'process my selection via a command'. So I presume you can concoct a command to handle all of this from within Sublime Text (or other code editors that run shell commands, like Textmate, bbedit…). The only issue is see is the tty changes, so you may need to set a shell variable or setup a way for sublime to prompt that (I have no idea how to do that TextMate 2 is my preferred editor). I don't use X11 much either so maybe this is all impossible?
*nix = everything is a file