loading...

Developing from an iPad

slooker profile image slooker ・6 min read

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, 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 (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. 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 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.

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

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

  • 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 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 or you can use my .vimrc.

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

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.

  • 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

The last two things I use in vim to make my life easier are Nerdtree Tabs and Ctrl-P. 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

Originally posted on blog.slooker.com

Posted on Aug 22 '17 by:

Discussion

markdown guide
 

Another interesting take on this is Giving the iPad a full time job which inspired me to try an iPad for real work.

Once you connect a Smart Keyboard cover to your iPad it just feels much more useful.

I can recommend Working Copy as a surprisingly powerful git client for iOS.

 

Giving the iPad a full time job is a great article, and I definitely recommend it to anyone who hasn't read it. Working Copy I enjoyed as a git client, but when it came down to it, for me, I really preferred command line.

But I'm a command line type of guy. :D

 

I'm working on an app that would give you a Linux shell that runs directly on your device, so you can do this sort of thing but without a DigitalOcean server or an internet connection. How useful does that sound?

 

I'd definitely be interested in trying it out! I'm mostly curious how powerful such a shell would be on a tablet.

 

At the moment it's pretty far away from actually running on an iOS device, but I'll keep you posted.

 

This is great, thank you! I'd be curious to see what it looks like switching back and forth to Safari. Do you need to touch the screen for that?

 

Sorry, I probably should have mentioned I'm using the keyboard smart cover! If you're using the keyboard smart cover, you can use command-tab to switch windows, same as if you were doing it on a macbook.

 

That works with other Bluetooth keyboards as well.

It does, I just meant I had a keyboard is all. :D

 

If you like GNU Screen, I'd recommend trying Byobu. It's more or less the same, uses an underlying screen or tmux, but I find it neater and easier to configure.

 

Nice! I'll take a look. Thanks for the info!