[TUHS] shell PS1/PS2 which survive cut-paste

Lyndon Nerenberg lyndon at orthanc.ca
Wed Dec 6 12:26:05 AEST 2017


> On Dec 5, 2017, at 5:28 PM, Kurt H Maier <khm at sciops.net> wrote:
> 
> I've used :; and ::; to good effect. Since : is a no-op, it just inserts
> noise into the history.

This fragment lives in my ${HOME}/.env on pretty much every machine I log in to.  If you 'export ENV=${HOME}/.env' in .profile, then configure sudo/doas to pass ENV through unmolested, this will follow you as you switch uids.

 _hostname=$(hostname | sed -e 's/\.hushmail\(inc\)*\.com$//')
 awd=$(which awd 2>/dev/null)
 if [ "${awd}" == "" ] ; then
        awd=':'
 fi
 setprompt () { PS1=": $(id -un)@$_hostname:$(pwd); " ; }
 cd () { command cd "$@" && setprompt && ${awd} ; }
 setprompt

It works with pretty much every Bourne/Korn shell variant I've stumbled across.  Adjust the _hostname bit to match the domains of the systems you regularly log in to, and drop the awd bits if you don't use plan9port.

--lyndon




More information about the TUHS mailing list