This guide shows some of the nice features of Sublime Text 3 (ST3):
Get it from here:
Go here and follow the instructions. Or see the link above for a video showing how to do it.
https://packagecontrol.io/installation
In order to be able to open local files from within Terminal run:
sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
It will ask you for your root password. This is probably the same as your local user login.
Now you can open a local file in the terminal like this:
cd /path/to/dir
subl script.R
and it will open up in ST3.
This plugin will allow you to automatically copy and paste a line or selected text in your script to be executed in the Terminal by pressing cmd
+enter
.
To install:
- In ST3 press
cmd
+shift
+p
to bring up the command pallette. - Type install packages and select the option called "Package Control: Install Package"
- It will load the available repositories and come up with a new window. Search for "SendText" and press
enter
. - It will install and you are done.
Now if you are in a script try it out:
- Open up an R script in
- Open up Terminal and type
R
to get a command line R prompt - In ST3 press
ctrl
+enter
on a line or selection of text and it should automatically copy it across to the last Terminal window you had selected, and then execute that line.
This works for any type of file in ST3 and onto any Terminal window (e.g. you can step through bash scripts or python scripts interactively).
You are going to create a tunnel on a chosen port every time you open up an ssh connection between your local machine and BlueCrystal 3 (BC3). This will allow you to open, edit and save files on BC3 using your local ST3 text editor.
First you need to choose a port. The following ones are taken so don't use them:
52799
53699
54747
For the tutorial I will just use port number 55555
.
On your local computer
-
Install the
rsub
and thePackageResourceViewer
plugins (i.e. using the same method used to install theSendText
plugin). -
You need to edit the
rsub
default preferences. To do this you will use thePackageResourceViewer
.- Open the command pallette (
cmd
+shift
+p
) - Navigate to "PackageResourceViewer: Open Resource" > "rsub" > "rsub.sublime-settings"
- This will open a new file called
rsub.sublime-settings
. Change the value for "port" to the port number you have chosen. - Save and close
- Open the command pallette (
-
Open (or create) the file
~/.ssh/config
and add the following lines:Host bluecrystalp3.acrc.bris.ac.uk ForwardAgent yes RemoteForward 55555 127.0.0.1:55555
On BC3
-
SSH into BC3
-
If necessary create a folder in your home directory called
bin
.mkdir -p ~/bin
-
Download this script and save it to
~/bin/subl
. -
Edit the port number on line 40 of the script to the port number that you have chosen.
-
Change the permissions to make it into an executable
chmod 755 ~/bin/subl
Now exit from BC3, restart ST3. Log back into BC3 and type
subl test.R
and it should open up a new file in ST3 called test.R
. If you edit and save the file you will see that you have created the file on BC3.