Difference between revisions of "OpenBSD CARP router/firewall zsh shell prompt"
Jump to navigation
Jump to search
(add zsh/openbsd/carp prompt hack) |
m (1 revision) |
(No difference)
|
Latest revision as of 21:49, 4 January 2013
Reasoning
Recently, I've been working with CARP clustered routers and firewalls pretty often,
and found that too often I'm troubleshooting the wrong machine.. This little hack
should help prevent that. It changes the hostname portion of my zsh shell prompt to
reflect whether the current machine is a master or a backup in the cluster.
It is only tested in zsh on OpenBSD.. if you try this elsewhere.. please update this page.
Zsh Prompt
My prompt looks like this:
^:jontow@ort1:~%
The 'ort1' portion is what this changes.. if you leave 'PROMPT_PERCENT=true' in here, it
should also take effect when you 'sudo zsh' or otherwise elevate privileges.
if [ "$(uname -s)" = "OpenBSD" ]; then # Are we the master? if [ "$(ifconfig carp | grep "carp:" | grep -e "MASTER" | head -1)" != "" ]; then PROMPT_HOST="^[[1;32m%m^[[0;0m" else PROMPT_HOST="^[[1;31m%m^[[0;0m" fi else PROMPT_HOST="%m" fi PROMPT_PERCENT=true ; export PROMPT_PERCENT PROMPT="%(?,^,_):%n@${PROMPT_HOST}:%~%# " ; export PROMPT