Notes on Plan 9 Front

An excellent distribution of Plan 9 from Bell Labs

Clear the terminal

9 Front doesn't have a clear command or keybinding (afaik) to clear the terminal of text.

Because everything in Plan 9 is a file, a terminal window is a file, specifically /dev/text. So I wrote a script named cls and placed it in bin/rc/ in my home directory:

#!/bin/rc
# cls: clear the screen
echo -n >/dev/text

(the -n option prevents echo from writing a trailing newline)

Command line history

I wanted to have way to search through the commands I ran previously. AfaIk, the commands you run aren't recorded anywhere by default. To remedy this I modified the bin/rc/cls script above. This will only record the commands run in a terminal prior to running cls. Not perfect, but good enough.

#!/bin/rc
# cls: clear the terminal and record history

# Save command history
grep 'term%' /dev/text | \
    awk '{sub($1, "", $0); sub("^ ", "", $0); print $0}' \
    >>/usr/$user/tmp/hist

echo -n >/dev/text

I also wrote an accompanying bin/rc/hst script to search and de-dup the history.

#!/bin/rc
# hst: search command history

grep $1 /usr/$user/tmp/hist | sort | uniq

Note that my grasp of rc(1) and the Plan 9 utils is pretty limited, so i'm sure that these scripts can be improved. An awk/rc linter in the vein of Shellcheck could be cool.

SSH on 9 Front

The Plan 9 terminal acts completely differently from a Unix terminal, so in order effectively remote into a Unix machine you'll want to emulate a glass TTY using the vt(1) program.

9 Front's ssh doesn't save the host's thumbprint by default, so you'll have to save it in /usr/$user/lib/sshthumbs via the suggested command.

TODO: figure out how to do SSH keys.

Git on 9 Front

9 Front comes with hg(1), a Mercurial client, but I and most other people these days are more comfortable with Git. Fortunately there's a Git implementation for Plan 9.

Git 9

Keep in mind that this is a Git implementation for Plan 9, not a port, so it works differently and is not 100% feature-complete. See the README for details and installation instructions.

Last Modified: 2021-01-28 Thu 20:18