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

External REPL

by fbehrens ST3

Sublime 3 Plugin to send lines of code to any REPL running in exteral Console (ConEmu or tmux)

Labels coding

Details

Installs

  • Total 5K
  • Win 3K
  • Mac 884
  • Linux 694
Dec 22 Dec 21 Dec 20 Dec 19 Dec 18 Dec 17 Dec 16 Dec 15 Dec 14 Dec 13 Dec 12 Dec 11 Dec 10 Dec 9 Dec 8 Dec 7 Dec 6 Dec 5 Dec 4 Dec 3 Dec 2 Dec 1 Nov 30 Nov 29 Nov 28 Nov 27 Nov 26 Nov 25 Nov 24 Nov 23 Nov 22 Nov 21 Nov 20 Nov 19 Nov 18 Nov 17 Nov 16 Nov 15 Nov 14 Nov 13 Nov 12 Nov 11 Nov 10 Nov 9 Nov 8
Windows 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0
Mac 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

What it is and how it works

This plugin is designed to optimize an interactive programmin workflow, in which you are working in the editor and a console window. There you are editing some programm in the editor, and then run it from the console. Or you are developing in a TDD fashion, so you run some tests from the console. Or you try out some

Installation

of this plugin

  • Install Sublime Text 3
  • Install Package Control
  • Install this Plugin from Sublime with CTrl-Shift-P / Package Control: Install Package / ExternalREPL

install console

On Windows install ConEmu On Linux or OSX install Tmux

  • Add Sublime Directory to Path. This adds the subl command.

  • Adjust ConEmu Settings

    • deactivate Keys & Macro/Paste/Confirm <Enter> keypress ConEmu Settings Plugin send command to Konsole with 'ConEmuC -GuiMacro:0 Paste(0,“command\n”)'

Linux

  • Installation Install Tmux for Mac / Linux

Tested Configuration

Sublime: 3 build 3083

Osx: 10.10.4 Yosemite Linux: Ubuntu 12.04, 14.04 Tmux: 2.0

Windows: 7, 8.1 ConEmu: 150513

Usage

Start session with tmux new -s repl. Start sublime from your console using the subl command. Command()-Shift P and typing External shows the commands. Hotkeys are shown via F1

repl Commands

cs-ENTER Sending selected text (or current line) and to the repl c-up Sending up arrow and Enter to the repl. This hopefully executes your last command. last repl command (doesn't work in pry on windows)

Editor Commands

Those Commands runs or loads the current file or executes test in the language of its syntax. It is possible to execute only the selected test. There is a convention for naming of testfiles. This makes it possible to switch between implementation and tests. The commands are run from the root of the sublime folder, so your project directory needs to be in the sublime side bar.

Language comment run load test framework test test_one testfile
powershell # . psspec psspec psspec -example .tests.ps1
ruby # ruby load minitest
gemfile bundle install
fsharp //
clojure ;
dot dot
markdown pandoc -> doc

cs-. load file
F5 run file
cs-t run testfile
cs-o excecute selected test
cs-' switch code<->test
cs-s Execute last editor Command sc-h Execute from history cs-c change directory/ns

Miscellaneous Commands

This is a grabbag for some stuff that i found useful at a time. cs-1 open explorer cs-2 dublicate file (This is quite useful) cs-3 open file on selected editor line (http:// in chrome or with sublime ) f1 show shortkeys cs-4 restructure mdTOC

Troubleshooting

Silent Failure

Check if console is in your path

Open the sublime console c-

import os
os.environ['PATH'] = "/usr/local/bin:" + os.environ['PATH']

Check if tmux or ConEmuC is on your path. If not consider starting sublime from the console using the subl command.

Check if you can send Keys to your console

Do this from another console and

# Tmux properly working
tmux send-keys -t repl 'ls'  C-m         

# ConEmu on Windows 
ConEmuC -GuiMacro:0 Paste(0,"dir\\n")

Tmux 101

  • From Tmux you can detach with Prefix(C-b) d.
  • and reattach to your tmux session with tmux a -t repl
  • Making the clipboard work between iTerm2, tmux, vim and OS X.

    tmux ls # list sessions tmux kill-session -t name # kill session tmux new -s repl # create new session with name repl tmux attach -t repl # attach to repl

using tmux with iTerm (on OSX)

iTerm has Tmux integration in the way that it can run enter tmux mode, where all windows / split panes are tmux windows / panes. Why is it so slow ?

tmux -CC new -s repl

License

MIT-License (see license.txt)