Developing from an iPad
Tags: ipad, developers, digitalocean
Published: 2017-08-22 01:59:25

---
title: Developing from an iPad
published: true
description: How I started writing code from my iPad
tags: iPad, Developers, Digital Ocean
---
When the iPad Pro came out, I was skeptical about it being useful for a developer for much, but I decided to splurge for one when I found out about [Duet](https://www.duetdisplay.com/), which lets me use it as a secondary screen for my Macbook.  This is invaluable for having documentation on a second monitor.

Recently, I've been reading up on a lot of tools that let you use your iPad as an actual development box, which makes it incredibly more useful to me.  To be clear, most of these things are going to require you to have a network connection on your iPad so you can connect to another server like [Digital Ocean](https://m.do.co/c/30da16b13cc2) (disclaimer, that's my referral link for DO), although you can use cloud based tools like Google Cloud, AWS, etc to push up to.  The only downside to the cloud based option is that you'll have to push your changes up every time you want to test something, as opposed to just being able to save, switch to Chrome, and reload.

##### Mosh
The first thing I had issues with when developing from an iPad was getting disconnected every time I stayed away from my SSH terminal too long looking at a page in Safari.  Then I stumbled across [Mosh](www.mosh.org).  Mosh uses UDP instead of TCP, and can be setup pretty easily on your server.  There's no lag, and it works even through network latency.  

##### Blink Shell
This leads me to my next app.  [Blink Shell](http://www.blink.sh/) is an iOS client for using SSH or Mosh.  It's $20, which I initially balked at, but it's well worth the money if you're going to connect to another server regularly from your iPad.  It's open source, so if you **really** don't want to spend that $20, you can always compile it by yourself from the [Github Repo](https://github.com/blinksh/blink).

##### Screen
GNU Screen is probably my most used app on a day to day basis.  GNU Screen lets you have multiple windows open that you can switch between with a few key strokes.  I'm an old school unix guy, and I hate having to use the mouse or take my fingers off the keyboard for anything.  GNU Screen lets me swap between windows easily without having to do that.  On most systems, you can install Screen by running `apt-get install screen` for an Ubuntu/Debian system, or `yum install screen` for a Red Hat/Fedora based system.  The **biggest** benefit though is that if you get disconnected, you can ssh/mosh back into your system and run `screen -x` and re-attach your screen session.  All of your work is still there, and you don't have to setup your environment each time.

Screen reads from `~/.screenrc` and I have mine setup to display a bar across the bottom so that I know what windows I have open and can easily switch to them.  

![GNU Screen screenshot](http://imgur.com/p1U0901.png)

Here is the `~/.screenrc` file I use to make this happen:

```
caption always "%{.bW}%-w%{.rW}%n %t%{-}%+w %= %{..W}[%l] %{..G}%2`@%H %{..Y} %D %d/%m/%Y %c "
termcapinfo xterm ti@:te@
defscrollback 30000 # Use a 30000-line scrollback buffer
autodetach on # Autodetach session on hangup instead of terminating screen completely
startup_message off # Turn off the splash screen
```

Here's a list of the most common commands I use for GNU Screen.  A more complete reference can be found [here](http://aperiodic.net/screen/quick_reference)

* The quick things that you want though are `ctrl-a` is the default "command" key
so you do `ctrl-a` then another key.
* `ctrl-a c` creates a screen
* `ctrl-a k` kills a single screen terminal, after you answer `y` at the prompt (but you can just type `exit` or `ctrl-d` at a prompt to exit it)
* `ctrl-a a` lets you change the name of the current screen (that’s what shows at the * bottom using that .screenrc file I showed you)
* `ctrl-a d` detaches your screen (brings you out of screen and back to the command prompt, * still saving your screen sessions)
* `screen -x` is what I run when logging in if I have a screen session already running, and if there’s not a screen session already running, I just run `screen`

##### Vundle
[Vundle](https://github.com/VundleVim/Vundle.vim#quick-start) is a VIM plugin manager.  It makes life a lot easier, and I'm not really certain how I lived without it before.  

To install it, assuming you already have vim installed, just run `git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim`.  You'll also need to edit your `~/.vimrc` file to use Vundle.  You can look at the [Vundle quick start docs](https://github.com/VundleVim/Vundle.vim#quick-start) or you can use [my .vimrc](https://paper.dropbox.com/doc/.vimrc-WSMgdT0JMm33Na1jca0R3).

Once you have it installed, startup vim, and type `:PluginInstall`

##### Bash
This one needs no introduction for most people, and is the default shell for most Linux distributions.  The one minor thing I add is the Git branch in my command prompt.  You can do this easily by adding this to your `~/.bashrc`

```
## Bash prompt stuff
parse_git_branch() {
     git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "
```

This gives you a prompt that looks like this (at least on my machine):

![Example bash prompt with github branch](http://imgur.com/uoDGwj1.png)


##### Vim
My editor of choice when using my iPad with Digital Ocean is vim.  I grew up using vi, so vim is second nature to me.  Here's a simple cheat sheet for the things I use most in vim, but you can find a much more lengthy cheat sheet [here](https://vim.rtorr.com/).

* `dd` will delete a line, `p` will put back a deleted line
* `V` to start a visual block, then you can use your arrows to move up and down to select what you want to use `dd` and `p` on
* `$` goes to the end of a line and `^` goes to the beginning of one
* Use #G` where # is a number, to go to a specific line.
* Use `m<Letter>` to mark something (like a bookmark) and `'<letter>` to go to it.  Example: if I’m swapping between two methods, I’ll do `ma` and `mb` to mark them, and then do `'a` and `'b` to go to them.
* Other than that, I just use regex replaces.  I’ll use `V` to select a block, then hit `:` which will change your prompt a t the bottom to `:'<, '>` and then you can do `s/word/replace/g` etc
* Typing `:` without a visual block will let you do `%s/word/replace/g` to do it in the whole file.
* `:wq` will write and quit, `:q` will quit an unedited file, and `:q!` will quit a file without saving, even if it’s been edited.

One of the things I can't live without with vim is this line in my `~/.vimrc`:

`map <Tab> <C-W>w<C-W>_` 

This makes it so that when I open up more than one file using `:split <filename>`, I can hit `<tab>` to switch between the two files, and it will maximize the file that I just switched to.

![Example showing switching between two files](http://imgur.com/JVoCXqv.gif)

The last two things I use in vim to make my life easier are [Nerdtree Tabs](https://github.com/jistr/vim-nerdtree-tabs) and [Ctrl-P](https://github.com/ctrlpvim/ctrlp.vim).  Nerdtree tabs are what you see on the left side of the image just above.  It's similar to most editors you see like VS Code, Sublime or Atom when you open a folder instead of a single file.

Ctrl-P is a fuzzy search file finder for vim.  If you type `ctrl-p` and start typing a word, it will do a search through your file tree to find it.

![Ctrl-P in action](http://recordit.co/pTvj3WTMER.gif)
 
_Originally posted on [blog.slooker.com](https://blog.slooker.us/developing-from-an-ipad/)_