Skip to content
Vince Buffalo edited this page Feb 24, 2020 · 6 revisions

I prefer to develop locally on my MacBook Pro whenever possible. My local NeoVim installation is customized to work best on OS X through iTerm2, so whenever I'm editing on a server, I face both a less optimal editing experience and latency issues. Occasionally I do have to develop primarily on a server, e.g. if running a program takes too many resources or takes too long to run locally on my laptop.

All projects have Github repos, which I keep private until a project is preprinted.

Tmux

While I could develop locally and use git, rsync, or scp to sync the files, I find this tedious and time consuming. I much rather develop directly on the server. Often I need access to an editing terminal tab, and a shell tab, and often many more tabs to get work done. To emulate this on a server, I use [tmux](https://github.com/tmux/tmux](tmux is short for Terminal Multiplexer). Since often I work on a few (sometimes related) projects at once, I use tmux sessions:

$ tmux new -s <project_name>

Then I use C-b c to create new windows, C-b p to go to the previous tab, and C-b n to go to the next tab (that's about 95% of the tmux I use, occasionally I'll need to do something else).

Note that tmux will maintain all these tabs even during connection loss. You can intentionally detach a session with C-b d. Sessions can be reattached with:

$ tmux attach -t <project_name> 

Running Jupyter Lab on a Notebook and Editing with Tmux

In the first tab, I often start a jupyter lab server instance, and then use SSH to tunnel to my local browser. I use this to start Jupyter lab:

# activate the relevant conda environment
$ jupyter lab --no-browser --port=8890.  # a different port per project

Then on your local machine:

$ ssh -Y -N -L localhost:8892:localhost:8892 sesame &
# [I 05:36:08.592 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
# [C 05:36:08.613 LabApp]

#    To access the notebook, open this file in a browser:
#        file:///home/vsb/.local/share/jupyter/runtime/nbserver-55159-open.html
#    Or copy and paste one of these URLs:
#        http://localhost:8892/?token=a48d356da1967842146cbf9091aa7bd02fa04398eba02e12

$  /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --app='http://localhost:8892/?token=<token here>'

Where the token is the unit string Jupyter lab returns.

Clone this wiki locally