Displaying current git branch in MacOS zsh prompt

Previous script for setting git branch in bash shell is here.

For zsh, here’s an approach from this gist – add to your ~/.zshrc:

function parse_git_branch() {
    git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p'
}

COLOR_DEF=$'\e[0m'
COLOR_USR=$'\e[38;5;243m'
COLOR_DIR=$'\e[38;5;197m'
COLOR_GIT=$'\e[38;5;39m'
setopt PROMPT_SUBST
export PROMPT='${COLOR_USR}%n ${COLOR_DIR}%~ ${COLOR_GIT}$(parse_git_branch)${COLOR_DEF} $ '

Troubleshooting serial terminal connections (VT Serial Terminal, VT132, Packet Radio TNCs) – part 2

In my previous post, I said I was going to test my two serial cables with every serial device I have to work out which combination worked and which didn’t to find out what the difference was. It didn’t take long to realize though that the DB25 to DB25 serial cable I have that I assumed was a null modem cable only worked with certain types of connections.

For example, it only worked with a VT terminal to a modem type device (in this case a PK-232 packet radio TNC), but not terminal to PC. In the first case that is a DTE to DCE type connection (which worked), whereas the second is DTE to DTE (which didn’t).

  • A DTE to DCE connection requires a straight through cable
  • A DTE to DTE requires a crossover connection (tx to rx, rx to rx)

This realization pretty much confirmed that the cable that was only working for DTE to DCE connectors was a straight through cable, and explained why it didn’t work elsewhere.

Long story short, I picked up a cheap null modem adapter that does the crossover for you, converting a straight through cable to a crossover:

From left to right:

  • USB serial dongle, connected to the Pi
  • DB9 to DB25 converter
  • DB25 to DB25 null model adapter
  • DB25 to DB25 straight through (converted to crossover with the null modem adapter)

And now I can successfully get a terminal logon to my Raspberry Pi:

To enable the serial terminal login via ttyUSB0, see this post.

Enabling serial tty login to a Raspberry Pi

Depending on what Raspbian version you are running on your Pi, the approach for enabling a serial tty login via a VT terminal differs, but on current/recent versions you can enable by enabling and starting this systemd service (steps from this post, and here):

sudo systemctl enable serial-getty@ttyUSB0.service

and then:

sudo systemctl start serial-getty@ttyUSB0.service

This assumes you are using a USB serial dongle and that it’s connected as /dev/ttyUSB0. You can check by doing a ‘ls /dev/ttyUSB*’ before you connect your USB serial adapter and after to check what device your USB dongle appears as.

If you’re running an older version of Raspbian not using systemd, you can add a line to /etc/inittab to initialize getty as described here.

Revisiting SunPCI driver install on Solaris 10

I’ve posted before on installing the SunPCI drivers on Solaris 10 but skipped a few steps. Sites to download the drivers are limited, but if you Google for the exact file name, you can find some locations, search for SUNWspci3.tar.Z

Unzip the file with:

uncompress *.Z

The untar with:

tar xf SUNWspci_13.tar

The SunPCI card in my Ultra60 is a 1.3 card, not 3, so be careful which package you download. Available options seem to be SUNWspci_13, SUNWspci2, SUNWspci3

Once you’ve untar’ed, run in the same folder:

pkgadd -d .

(not as I said before to cd into the untar’d folder). At this point you should be able to follow the rest of the steps in the previous post.

I’m reinstalling and setting up Solaris 10 on this box since I spent some time installing FreeBSD and then Solaris 8, and decided Solaris 10 was actually the better option, so I’m going that to that again (Solaris 8 I couldn’t get to install).

At some point I must have mounted a shared drive on my NAS to copy files to/from this box, so I’ll also take a look at getting that going again (I don’t think I took any notes), I could have used ftp. Will see what works.