ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Send​REPL

by randy3k ST3

Send Text to Terminal, ITerm, ConEmu, Cmder, Tmux; R (RStudio), Julia, IPython REPL

Details

Installs

  • Total 2K
  • Win 980
  • OS X 900
  • Linux 453
Mar 26 Mar 25 Mar 24 Mar 23 Mar 22 Mar 21 Mar 20 Mar 19 Mar 18 Mar 17 Mar 16 Mar 15 Mar 14 Mar 13 Mar 12 Mar 11 Mar 10 Mar 9 Mar 8 Mar 7 Mar 6 Mar 5 Mar 4 Mar 3 Mar 2 Mar 1 Feb 28 Feb 27 Feb 26 Feb 25 Feb 24 Feb 23 Feb 22 Feb 21 Feb 20 Feb 19 Feb 18 Feb 17 Feb 16 Feb 15 Feb 14 Feb 13 Feb 12 Feb 11 Feb 10 Feb 9
Windows 3 4 7 9 10 11 3 3 4 12 10 5 8 6 6 3 10 2 3 3 7 2 6 7 10 7 9 7 1 5 4 10 6 10 2 7 7 3 6 13 10 6 3 6 6 7
OS X 1 1 6 9 3 6 2 1 6 4 5 5 4 3 1 5 4 4 4 0 3 4 4 7 5 5 3 3 2 0 6 8 5 5 3 0 1 10 4 7 6 3 2 2 4 6
Linux 1 3 1 2 8 4 1 5 1 6 1 0 7 1 3 2 1 2 3 3 3 2 0 2 2 5 1 3 2 3 3 1 1 2 4 3 1 2 1 5 2 1 3 0 4 2

Readme

Source
raw.​githubusercontent.​com

SendREPL for Sublime Text

Send Text to Terminal, ITerm, ConEmu, Cmder, Tmux; R (RStudio), Julia, IPython REPL. This is a rewrite of SendTextPlus which aims for higher extensibility and higher self-containedness.

Note: IPython console is assumed for Python syntax.

Following Programs are supported

  • Mac: Terminal, iTerm (>=2.9), Tmux, Screen, RStudio Desktop, R GUI, RStudio and Jupyter running on Chrome and Safari
  • Windows: Cmder, ConEmu, R GUI, RStudio Desktop
  • Linux: Tmux, Screen, RStudio Desktop
  • Others: SublimeREPL

Installation

You could install SendREPL via Package Control. If you are using Linux (Windows), the corresponding platform dependency xdotool (pywin32) will also be installed automatically.

Usage

Select a program using the command SendREPL: Choose REPL Program in command palette. The default program is Terminal for Mac, Cmder for Windows and tmux for Linux.

  • cmd+enter (Mac) or ctrl+enter (Windows/Linux)

    If text is selected, it sends the text to the program selected. If no text is selected, then it sends the current block (if found). Finally, it moves the cursor to the next line.

  • cmd+\ (Mac) or ctrl+\ (Windows/Linux): change working directory (R, Julia and Python (IPython) only)

  • cmd+b (Mac) or ctrl+b (Windows/Linux): source current file (R, Julia and Python (IPython) only)

    SendREPL uses Sublime build system to source files, you might have to choose the Source File option in a pop up window.

Custom Keybind

It is fairly easy to create your own keybinds for commands which you frequently use. For example, the following keybind run the R command source("<the current file>") in the active program.

{
    "keys": ["super+shift+e"], "command": "send_repl",
    "args": {"cmd": "source(\"$file\")"},
    "context": [
        { "key": "selector", "operator": "equal", "operand": "source.r" }
    ]
}

SendREPL understands the following variables in the cmd field:

  • $file, the full path to the file
  • $file_path, the directory contains the file
  • $file_name, the file name
  • $file_basename, the file name without extension
  • $file_extension, the file extension
  • $project_path, the active folder, if not found, use the directory of current file
  • $selection, the text selected, or the word under cursor
  • $line, the current line number

User settings

User setttings should go into the user key in the SendREPL.sublime-settings. For example

{
    "user":{
        "python" : {
            "prog": "terminal",
            "bracketed_paste_mode": true
        }
    }
}

Some details about block detection

SendREPL uses the following logic to expand cursor when sending text.

  • R blocks are detected by {,} pairs or knitr-spin #+ decorators.
  • Julia blocks are detected by begin, end pairs and indentations.
  • Python blocks are detected by indentations or by # %%/# In[] decorators.
  • Markdown fenced code of Markdown Extended and R Markdown is also supported.