My iPad Setup

Caveats and Story

My laptop is broken. I am away from office. I have an iPad Pro 2020. I got my office desktop's magic keyboard and trackpad. In this post I am discussing if iPad can help given that I do not have (physical) access to my main computers. Would I recommend this over a main computer - No! But, can you do some things on the iPad reasonably well enough given keyboard and trackpad - Yes!

The Hardware

The magic keyboard and the magic trackpad greatly increase the iPad experience and make it programmer friendly.

Setting up an iPad for programming

Setting up the terminal app (a-Shell)

Configuration

First, after installing a-Shell, I like to set the font size, terminal background and foreground color. Here is how the a-shell app looks like

config -b black -f white -s 20

Text editing and bookmarks

Sometimes I like using vim for editing documents and interfacing with WorkingCopy. a-Shell provides vim!

I like to setup a bookmark to the WorkingCopy folder so that I can direcly edit files in that location.

I do so by: writing pickFolder in a-Shell and setting it to WorkingCopy folder. Now I can set a bookmark to this location. I do so by: bookmark git in the current location (set by pickFolder)

Git

Interestingly, the latest testflight version of a-shell also provides a "Git-like" interface called libgit2. Configuring it requires specific steps that I'm writing below. Some of these steps are borrowed from this nice tutorial and some are specific to a-shell that I was able to get working courtesy a Twitter discussion with the creator of a-shell.

Now, the steps.

First, we need to create a new ssh key.

We do so by

ssh-keygen -t rsa -b 4096 -C "email@domain.com"

While configuring I did not setup the passphrase.

The private and public keys are stored in .ssh with the name id_rsa

$ ls -lah .ssh|grep "id"
-rw-------   1 mobile  mobile   3.3K Jun 14 15:43 id_rsa
-rw-------   1 mobile  mobile   747B Jun 14 15:43 id_rsa.pub

Next, I copied the public key in a newly generated ssh key in Github and gave it a name.

Next, I modified .gitconfig as follows

$ cat .gitconfig 
[user]
        email = MY EMAIL ID
        name = MY NAME
        identityFile =  id_rsa 

Now, I was almost done!

I was able to push and pull from some old Github repositories but the same did not work with the newer repositories. Again, after a discussion with the creator of a-shell, I figured, this was due to the fact that Github changed the name of the default branch as "main" instead of the earlier "master" whereas libgit2 implementation was expecting "master".

As a quickfix I renamed the branch on my Github repo as "master" and for now set the default branch to be named "master".

Finally, I am able to pull and push to the repositories. The next image infact is showing commits and pushes made to the repository generating the blog post you are reading.

SSH/SFTP

There are a couple of amazing apps: Termius and SecureShell. Both have very neat interfaces. I found the intergrations with the Files app very good!

The GIF below shows the SecureShell app in action where I transfer a file from my local storage (iPad) to remote server, process that file, and quickly copy the processed file back to local storage.

Another great functionality of the SecureShell is the "Offline" folder.

Another setting that I use is the Powerline fonts on my remote systems. Using Fontcase, I installed the corresponding powerline fonts on the iPad so that my SecureShell session looks great.

![](%20site.baseurl%20/images/powerline-combined.png "Powerline fonts installed via Fontcase allow special characters on the remote terminalls (above image without powerline font on iPad, below one with powerline font")

Some other amazing tools

I like the "view" utility in a-shell a lot. It can quickly help you preview various filetypes.

Also, as a quick tip, one can use Command + W to quickly exit the preview and use the back and forward keys to cycle through the files. This is very useful!

I also like the fact that the convert tool now comes in inbuilt. It can convert between a variety of formats easily.

pbcopy and pbpaste are very convenient utilities to copy to and from the clipboard. Here is how I copied the content of factorial.py into the clipboard.

pbcopy < factorial.py  

Shortcuts

a-Shell interfaces nicely with Shortcuts. The following gif shows an interface where I take an input from Shortcuts app -> Pass it to a Python script and execute it inside a-shell -> Store the results in a text file -> View the content of the text file in Shortcuts.

The link to this shortcut is here

The following is the simple Python script I used called factorial.py

import math
import sys

num = int(sys.argv[1])
print(f"The factorial of {num} is {math.factorial(num)}")

The following is an image of the shortcut.

Based on the suggestion here, I used pbcopy to copy the content to the clipboard and use it directly. It reduces the number of lines!

Using the WorkingCopy App

WorkingCopy is a very nicely made Git app on the iPad. It is one of the best made apps I have used!

I'll let the pictures do the talking.

Editors

I use one of the following for editing:

Setting Linux/Mac machine and iPad for Python programming (via Jupyter notebooks)

On the Linux/Mac (remote server) machines I set up Jupyter notebooks as follows:

First, I create the configuration file via: jupyter notebook --generate-config

Next, In ~/.jupyter/jupyter_notebook_config.py change


c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.allow_origin = '*'
c.NotebookApp.port = SET YOUR PORT
c.NotebookApp.open_browser = False

Set password using:

jupyter notebook password 

Run notebook as:

nohup jupyter notebook& 

On the client end (iPad in this case), I use one of the following two ways to access remote Jupyter instances:

VNC connection

I tried a few VNC software and found AnyDesk to work fairly well. I did a bunch of small settings tweak.

Email client

I like the Spark app.

PDF management

The iPad Files app is a fairly well made app. Perhaps not as functional as the Mac Preview app, but, does some things well.

For instance, merging multiple PDFs is easier (for me) than doing the same on Mac. One just needs to select multiple files and then "right" click to "Create PDF"

I use the following ffmpeg command (inside a-Shell) to create this GIF courtesy this excellent tutorial from GIPHY folks

PDF viewing

The Documents app has a very nice pdf viewing experience. It gives the "full-screen" experience on connected displays and can potentially be an excellent pdf viewer for showing my slides on the projector in the classroom setting.

Another advantage of the Documents app PDF viewer is that we can change the tone to Sepia or Dark. The following image shows the view I get when I change the tone to Dark.

When connected to an external display, the PDF viewer gives various options. In the next image, I show the view when I "focus" on a part of the slide.

Finally, the image below shows the "focused" slide on the external display.

ffmpeg -i Video.MP4  -filter_complex "[0:v]  fps=12,scale=720:-1,split [a][b];[a] palettegen [p];[b][p] palette
use" CombinePDF.gif

Another alternative is to use the following shortcut to convert the screen recorded video into a GIF

Some Safari keyboard shortcuts

Conclusions (and rants)

For the long run, ofcourse, I would not recommend this kind of a setup. There is some learning and fun in getting a "resticted" device to function well, but as a main machine, probably no, at least not for the next few months. A comparably priced laptop (say M1 Macbook Air) would offer a lot more.

There are many things I'm missing:

Some of the above may be resolved over the next updates and the major iPadOS15 updates. Though, I do not expect most of them to be resolved anytime soon.