NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Tweeking the PS1 (in ksh)



I want the prompt changed:

Black-text  on white background.
Text is "tgruhn$ "


Put this in a file (say, ~/lib/ps1.ksh), then source it in ~/.profile, ~/.kshrc,
~/.shrc, etc.

```
# Coloured prompts--ksh(1) only.
#

# non-print marker
X=$(printf '\x01')

# \r circus
CR=$(printf '\r---')
CR=${CR%---}

BLD=$(tput bold)		# bold attribute
RST=$(tput sgr0)		# reset all attrs.

# ANSI colours (foreground)
FBLK=$(tput setaf 0)		# black
FRED=$(tput setaf 1)		# red
FGRN=$(tput setaf 2)		# green
FBRN=$(tput setaf 3)		# "brown"
FBLU=$(tput setaf 4)		# blue
FMAG=$(tput setaf 5)		# magenta
FCYN=$(tput setaf 6)		# cyan
FWHT=$(tput setaf 7)		# white
FYEL=$(tput bold setaf 3)	# yellow

# ANSI background
BBLK=$(tput setab 0)
BRED=$(tput setab 1)
BGRN=$(tput setab 2)
BBRN=$(tput setab 3)
BBLU=$(tput setab 4)
BMAG=$(tput setab 5)
BCYN=$(tput setab 6)
BWHT=$(tput setab 7)

ME=$(id -nu)			# whoami
P=$(test $(id -u) -eq 0 && printf '#' || printf '$')	# `#' or `$'

export PS1="${X}${CR}${X}${FBLK}${BWHT}${X}${ME}${X}${RST}${X} ${X}${BLD}${FRED}${X}${P} ${X}${RST}${X}"
```

-RVP


Home | Main Index | Thread Index | Old Index