Package like SendCode in Sublime


#1

Does there exist a package in Atom that allows the user to send a selection of lines to a terminal? I mean something like this in Sublime: https://github.com/randy3k/SendCode. I’m mostly interested in running Python code line by line into a IPython terminal (I’m not looking for the Hydrogen package).


#2

All of the code runner packages work by sending lines of code or whole files to other programs. The one that gives you the most freedom is process-palette.

What syntax would you use to run the code into IPython from the command line?


#3

Thank you for the tip.

I would like to select some lines of code and Ctrl + Enter to send them to a terminal (and if no selection is used then send the line of code where the cursor is), where I’m running IPython.


#4

How do you do that using the command-line interface? If you tell me that, I can tell you how to configure process-palette.


#5

In Sublime I simply add the SendCode package, choose where I would like to send the code (tmux, RStudio, etc.) and then I can simply send the code to the chosen destination using Ctrl + Enter. I usually use tmux. SendCode does not require me to have any special REPL open in tmux, it will send it there no matter what, which is pretty nice. Slime in vim is quite similar.


#6

You could use Atom package ‘platformio-ide-terminal’ for that.

"
command: platformio-ide-terminal:insert-selected-text
Run the selected text as a command in the active terminal.
"

but I use package term3 for ipython
and wrote a few lines of javascript code in my init.js to add this functionality.


#7

I don’t know anything about tmux and what you’re working on is a workflow that I haven’t had any experience with. I can find the code file that determines how the commands are sent to tmux, but I don’t know anything about how that looks or feels from the user side. I need you to help explain the actual sequence of commands that get sent to the shell and I can tell you how to make that happen in Atom.


#8

It’s basically the same workflow as one has for example with Jupyter notebooks, where one can run one row or selection at the time, but here it is done using the editor and the terminal.

I don’t know the exact commands that happen with SendCode, I would have to take a look at the source code for SendCode to understand that.


#9

I’ll try this. Thanks!