I wanted to use a local REPL on my macbook to run code on my remote giant research machine. After some fiddling, I figured out how to do it.
Prerequisites:
- working key-based authentication for SSH (Sublime can't prompt for a password)
- Working SublimeREPL installation
Then add the following as a menu item in Preferences -> Browse Packages... and then navigate to SublimeREPL/config/Python/Main.sublime-menu. Add a new menu option along the default ones:
Prerequisites:
- working key-based authentication for SSH (Sublime can't prompt for a password)
- Working SublimeREPL installation
Then add the following as a menu item in Preferences -> Browse Packages... and then navigate to SublimeREPL/config/Python/Main.sublime-menu. Add a new menu option along the default ones:
{"command": "repl_open", "caption": "Python - Remote", "id": "repl_python_remote", "mnemonic": "c", "args": { "type": "subprocess", "encoding": "utf8", "cmd": ["ssh", "username@ip_address", "/usr/bin/python", "-i", "-u"], "cwd": "$file_path", "syntax": "Packages/Python/Python.tmLanguage", "external_id": "python", "extend_env": {"PYTHONIOENCODING": "utf-8"} } }
A couple changes to the user settings for SublimeREPL make the REPL better:
{ "show_transferred_text": true, "suppress_echo" : false }
For R-like command-enter execution, add it in the default keymap file:
[{ "keys": ["super+enter"], "command": "repl_transfer_current", "args": {"scope": "selection"}}]
I haven't tried wit Sublime Text 3 but it should be the same procedure. Code runs from the user directory (i.e. the cwd directive doesn't seem to do anything).