Home Download Buy Blog Forum Support

Plugin for sending text to terminal

Plugin for sending text to terminal

Postby wch on Tue Apr 17, 2012 8:05 pm

I find it really useful to be able to send commands from an editor window to a terminal, so I've created a plugin for sending text to a Mac Terminal window: https://github.com/wch/SendText. (The code is based off of https://github.com/karthikram/Rtools)

If text is selected, it will send the selection to the terminal when you press cmd-Enter; if no text is selected, it will send the current line to the terminal and move the cursor to the next line.

I hope to add the following features in the future:

  • Allow easy customization of the target program (e.g., iTerm, gnome-terminal, etc)
  • Work on Linux and Windows
  • Allow customizing the target program based on the file type

I hope this will be useful to others. I presently don't have a Linux or Windows machine to work on, and I'm not sure how to send text to programs in Linux or Windows. If you know how to do these things, please feel free to fork the repo and submit pull requests adding these features.
wch
 
Posts: 5
Joined: Tue Apr 17, 2012 1:37 am

Re: Plugin for sending text to terminal

Postby wch on Mon Apr 23, 2012 6:08 pm

I've updated it to work with:

  • Terminal.app on Mac
  • iTerm on Mac
  • tmux on Mac and Linux
wch
 
Posts: 5
Joined: Tue Apr 17, 2012 1:37 am

Re: Plugin for sending text to terminal

Postby nollo on Fri May 25, 2012 9:41 pm

You plugin is very nice and very useful !

1. how do you use gnome-terminal ? I only managed to use tmux
2. What is the buffer size ? I have a big text to send and when I select it and send it, there is no effect.
3. A cool feature will be to send everything until a punctuation. For example :
SELECT * FROM MYTABLE;
SELECT * FROM MYTABLE
WHERE MYCOLUMN = "123";
If you are on the third line, if you send it, it will send untill it reachs the ;. I don't know if you understand what I mean.

By the way, nice job !
nollo
 
Posts: 19
Joined: Sat Mar 03, 2012 10:47 am

Re: Plugin for sending text to terminal

Postby wch on Tue May 29, 2012 5:17 pm

Great, glad you find it useful!

1. I'm not sure how to make it work with gnome-terminal... On OS X, it's possible to send text to a Terminal using Applescript, but I don't know of a way to do that with gnome-terminal (or Windows terminals). If anyone knows how to do this, please chime in!

2. I'm not sure what the max buffer size is... my guess is that in your case, it's limited by tmux. I just tested it with ~330 lines of code (~11500 characters) on OS X Terminal and it works fine. How much is too much on your system?

3. Do you mean if you start on the second line, it'll go until the ;?
wch
 
Posts: 5
Joined: Tue Apr 17, 2012 1:37 am

Re: Plugin for sending text to terminal

Postby nollo on Mon Jun 04, 2012 11:14 am

1: OK, I saw gnome-terminal on the page of the project, that's why I asked.

2: Ah yes, it may be the buffer size of tmux the problem, I'll figured out ! :)

3: Yes, for example if you start at line 2 on the word MYTABLE, you'll send SELECT * FROM MYTABLE WHERE MYCOLUMN = "123";
So you send all text between two ";".
In SQL developper for oracle I have this feature. From a list of request, I just have to press F9 to send the request under my cursor, it is very useful.
nollo
 
Posts: 19
Joined: Sat Mar 03, 2012 10:47 am


Return to Plugin Development

Who is online

Users browsing this forum: Exabot [Bot] and 5 guests