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 878
  • Linux 686
Apr 20 Apr 19 Apr 18 Apr 17 Apr 16 Apr 15 Apr 14 Apr 13 Apr 12 Apr 11 Apr 10 Apr 9 Apr 8 Apr 7 Apr 6 Apr 5 Apr 4 Apr 3 Apr 2 Apr 1 Mar 31 Mar 30 Mar 29 Mar 28 Mar 27 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
Windows 0 1 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 1 1 1 0 0 0 1 0 1 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 2 0 0 0
Mac 0 0 0 0 0 0 1 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
Linux 0 0 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 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)