Blink Shell for iOS
August 10, 2017
Blink Shell is a unique and powerful shell app for iOS for connecting to remote hosts. Although it is perhaps not quite as polished as Prompt, my other favorite iOS SSH client, it has several features that Prompt does not.
When you first start Blink, there are no buttons or menus, as one expects from an iOS app. Instead, you are greeted with a cryptic blink>
prompt in a black terminal with tiny white text.
This might be a bit disconcerting, but after a brief moment of panic, you will probably start to experiment with some commands. If you type an invalid command, Blink will inform you that you can type “help” to see a list of commands:
Blink: v7.0.1. Jul 11 2017
Available commands:
mosh: mosh client.
ssh: ssh client.
ssh-copy-id: Copy an identity to the server.
config: Configure Blink. Add keys, hosts, themes, etc...
help: Prints this.
exit: Close this shell.
Available gestures and keyboard shortcuts:
two fingers tap or cmd+t: New shell.
two fingers swipe down or cmd+w: Close shell.
one finger swipe left/right or cmd+shift+[/]: Switch between shells.
cmd+alt+N: Switch to shell number N.
cmd+o: Switch to other screen (Airplay mode).
cmd+shift+o: Move current shell to other screen (Airplay mode).
cmd+,: Open config.
pinch: Change font size.
If you have a Smart or Bluetooth keyboard attached—and you probably should to get the most out of Blink—then instead of typing a command you might try holding ⌘ to see a list of keyboard shortcuts.
You can see that pressing ⌘, is an alternative to typing config
to enter the app settings. Note that this is the same keyboard shortcut for opening the preferences window in most macOS applications. You can also do normal shell things like Control+L to clear, Control+D to log out, and so on.
Configuring and Connecting to Remote Hosts
Blink works with both SSH and Mosh, but before connecting to a remote host you should first import your SSH login keys and set the default username for SSH connections.
You can issue the ssh
command with the usual flags, such as ssh -l <username> <hostname>
, but you’ll want to configure frequently-accessed hosts for convenience. Each host is given an alias, say <host>
instead of <hostname>
, so that once configured you can simply type ssh <host>
or mosh <host>
to connect with the pre-configured hostname, username, port, etc.
SSH
For basic SSH access to a host, you’ll need provide the following:
- Name for remote host entry. Note that this the name you’ll use to connect (e.g.,
ssh <name>
) and it is case sensitive. - IP address or hostname.
- Port used to access SSH (if different port 22).
- Your username.
- Either your password or an SSH key to use.
Mosh: Mobile Shell
Most readers probably use SSH already but may not have heard of Mosh, which is much newer. Mosh is designed to provide robust remote connections with roaming when your IP changes (e.g., switching from WiFi to cellular) and intermittent connectivity. Mosh piggy-backs on top of SSH, so if you already have remote SSH access you only need to install a user-level mosh-server
binary to enable Mosh access.
If you have installed Mosh on the remote host, then you may also need to provide the following:
- Path to
mosh-server
binary (e.g.,/usr/local/bin/mosh-server
).1 - Optional UDP port (e.g., if you need to use a custom port to get through a firewall). By default, Mosh uses the first available UDP port between 60001 and 60999.
- Optional command to run on startup (e.g.,
screen -d -R
ortmux attach -t default
).
If you use Homebrew on macOS, installing Mosh is as simple as this:
brew install mobile-shell
Customizing Modifier Keys: Caps Lock as Control
One of Blink’s most powerful features is the ability to customize the keyboard modifier keys. In fact, the reason I found Blink to begin with is it’s ability to use Caps Lock as a Control key (although there is an important caveat, discussed below).
If you set Caps Lock to be a Control key, there is a very important caveat: Caps Lock may be in an unexpected state when you leave and re-enter blink. This is due to the limitations of iOS development. There is a GitHub issue devoted to this problem if you’d like to read more about the technical details.
To summarize the issue, you can think in terms of two distinct Caps Lock states: one global in scope and one local. There is the iOS system-wide Caps Lock state and then the local state within the Blink app. If you are using Caps Lock as the control key, each time you press Caps Lock the system state is toggled but the Blink Caps Lock state remains off. The issue is that when you leave the Blink app, other apps honor the system state, which could be either on or off depending on whether you’ve pressed Caps Lock an even or odd number of times during your Blink session.
If you have an Apple wireless keyboard with a Caps Lock light, the light follows the system state every time you use Caps Lock in Blink, so this can at least help you track the state. Overall, I’ve found that the annoyance of this issue is small in comparison to the convenience of using Caps Lock as Control in Emacs and for other shell commands.
Another caveat is the small delay between when Caps Lock is pressed and when it is registered. When I quickly type control sequences as fast as I typically do—expecting no delay—the Control key part is not recognized. For example, to send ^C
you’ll need to press Caps Lock and hold it for a fraction of a second longer than you typically might before pressing C. I don’t mean to overstate this issue, but I find that I do have to be more deliberate about entering control sequences.
Customization
There is a Blink Shell Theme Gallery with a huge selection of themes which you can access in Settings > Appearance > Add a new theme.
In the screenshot, I’m enjoying the Fira Code font—the same font I use in Emacs, yes, a monospaced font with programming ligatures—with the Arthur theme for Blink.
The keyboard shortcuts are also customizable. This includes the keys for switching to the previous and next shells, creating a new shell, closing a shell, and configuring Blink.
Getting Blink Shell
You can purchase the Blink Shell app on the App Store. Blink is also open source, so you can take a look at the source code on GitHub.2
-
This is the “Server” setting, which I found to be confusing at first. This field is not asking for a hostname (again), it is provided in case your
mosh-server
binary is not in your defaultPATH
. ↩ -
If you’re looking at the source, you probably also want to see Nicolas Holzschuch’s branch, where he has added several common Unix commands for file management (
ls
,cp
,rm
,mkdir
, etc.), text processing (cat
,grep
,wc
), file transfer (curl
,scp
,sftp
), and so on. ↩