Sublime Forum

Plugin for sending text to terminal

#1

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: 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.

0 Likes

#2

I’ve updated it to work with:

  • Terminal.app on Mac

  • iTerm on Mac

  • tmux on Mac and Linux

0 Likes

#3

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 !

0 Likes

#4

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 ;?

0 Likes

#5

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 ! :smile:

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.

0 Likes

#6

Hi …
Just wanted to say thanks for this package. I use it everyday and I’m enjoying it for my system administration work. Job well done.

0 Likes