How to Optimize Working On the Zoo

## How Do I Show Off to Underclassmen and Make My Screen Look Straight Out of the Matrix?

Here are some VERY USEFUL tools that can make your experience doing CS at Yale a breeze. I'm going to be throwing a lot of technical information at you in the next few paragraphs, so Google away if you're unsure about anything and/or shoot us an email at dsac@yale.edu for clarification.

## Connecting to the Zoo

To work in the Zoo remotely, you have to have an Internet connection and a command line. To ssh into the Zoo, run

```
$ ssh <yourNetID>@node.zoo.cs.yale.edu

```

and enter your NetID password when prompted. To access a specific server in the Zoo (Zebra, for instance), run

```
$ ssh <yourNetID>@zebra.zoo.cs.yale.edu

```

and enter your NetID password when prompted. In terms of file access, it doesn't matter which Zoo node you use to connect. All system executables and your files will be the same.

## Transferring Files From/To the Zoo

You can copy files between your local machine and Zoo servers by using scp (secure copy). To run scp, you have to be on your local machine (aka you have to be outside of your ssh session).

```
$ scp /path/to/local/file.txt <yourNetID>@node.zoo.cs.yale.edu:~/path/to/directory/where/you/want/that/file/

```

The above will copy file.txt to the directory on specified after the colon in the second argument on the Zoo. To do the reverse, run

```
$ scp <yourNetID>@node.zoo.cs.yale.edu:~/path/to/Zoo/file.txt /path/to/local/directory/

```

If your scp command worked, you should see something like this:

```
file.txt                                         100% 3150     3.1KB/s   00:00

```

## Vim (aka the Greatest Thing Since Sliced Bread)

To work remotely on the Zoo, you need an editor. And what better editor to have by your side than trusty, faithful, efficient, lightweight, practical Vim? Vim stands for Vi Improved and will save your life so many times you have no \*idea\*. People will try to lure you into the depths of Sublime Text SFTP, but stay strong! Vim has a bit of a learning curve in the beginning but will pay off infinitely many times in the long run because it's more powerful, accessible, and standardized. If you've never used Vim before, you can walk through a step-by-step tutorial of how to navigate vim by running

```
$ vimtutor

```

If you want to grab life by the horns and ditch those training wheels, jump straight into it and start Vim by running

```
$ vim [filename]

```

I won't go into the nitty gritty because there's too much to cover and too many great Vim users on the Internet who've written more than enough documentation, so take a look at:

* this quickstart guide for a quick-and-dirty rundown of How To Vim
* this interactive tutorial if you want a fun, comprehensive walkthrough of Vim's functionality
* this game if you want to practice burning that navigation muscle memory into your mind
* this cheat sheet for reference

One gem I will offer, though, is that you can open multiple files as tabs in one window by running

```
$ vim -p file1.py file2.js file3.c

```

and navigate between them easily by enabling mouse mode:

```
: set mouse=a

```

## Sublime SFTP

Sublime SFTP is a great solution for working on the Zoo. It allows you to map local files to files on the zoo, allowing you to work on your own machine while automatically syncing to the zoo. Use "Map to Remote" to link a local folder with a zoo folder. If you choose this solution, it's easiest to set up SSH keys (one tutorial is here) on the zoo so you can sign in (and thus sync) without typing a password. Then, by setting "upload\_on\_save" to true, you can hit save on your local machine and immediately see those changes reflected on the zoo.

If the SSH connections dies (changes aren't being pushed to the zoo), try quitting and reopening Sublime. This can happen occasionally if your computer goes to sleep or disconnects from wifi.

## tmux (the Greatest Thing Since Vim)

tmux is a terminal session manager, or what the kids call a "terminal multiplexer." It allows you to do work with split screens on terminal windows, which is invaluable when you have multiple files you need to see all the same time. (Like this! Or even this.  Knock yourself out.) You can start tmux and open a new pane by doing

```
$ tmux
Ctrl-B % 				<-- for vertical split
Ctrl-B "				<-- for horizontal split

```

Switch between the two panes with <Ctrl-B o>.

More importantly, tmux allows you to save sessions on remote servers! That means, losing data because of Zoo connection timeouts can be a thing of the past!

There are countless tmux tutorials on the Internet, and people have written how-to guides far more comprehensive and succinct than I did here, so I strongly encourage you to do a bit of research and familiarize yourself with it. You can get a crash course about using tmux here and here.

## Aliasing in Bash

I've thrown a lot of commands at you over the course of this article, and some of them were not short. If you don't want to type out node dot zoo dot cs dot yale dot edu every time you want to ssh into the zoo (or any other long command), create an alias. Do this by putting the following line into your `.bash\_profile` (it could also be called `.bashrc`. If neither `.bash\_profile` nor `.bashrc` show up in your home directory when you run `ls -lA`, just create one of them by making a new file in your home directory):

```
$ alias zoo='ssh <myNetID>@node.zoo.cs.yale.edu'

```

## Conclusion

Got more tips on how to be a master of working with the Zoo? Email us at dsac@yale.edu.