Gerard Lally dixit:
>OK my last question: I am lost! I am trying the following:
>
>PS1 =
>1) line break
>2) reverse video, right-aligned $SHELL, $TERM, and $TTY, line break
This will not work without “bracketing” the ANSI codes in some
special character (see the manpage for this, the character is the
first byte of $PS1 when its second byte is an ASCII CR).
>3) $hostname, line break
>4) job number, path (~ if $HOME, ~/org if a subdir of $HOME, full path
>otherwise), line break
>5) user name, prompt ($ if user, # if root)
>
>This is what I have: a complete mess, but I am learning slowly. I have
>grabbed snippets from various places, including some of yours.
>[\e[1;36m!\e[0m]$(local d=${PWD:-?} p=~ [[ $p = ?(*/) ]] || d=${d/#$p/~} print
>-nr -- "[\e[\
This is missing a newline (or semicolon) behind “p=~”.
>path (not ~/org, for example), and I am not able to get the SHELL and
>TTY variables to print on the first line. I also get the following
>error:
>
>mksh: typeset: [[: is not an identifier
Let me try to fix that up for you (and optimise it a bit)…
PS1=$'\001\r\n\001\e[1;7m\001${|
typeset -R$COLUMNS REPLY="[$SHELL|$TERM|$(tty)]"
}\001\e[0m\001'"[${HOSTNAME:=$(hostname)}]
"$'[\001\e[1;36m\001!\001\e[0m\001]$(
local d=${PWD:-?} p=~
[[ $p = ?(*/) ]] || d=${d/#$p/~}
print -r -- "[\001\e[1;35m\001$d\001\e[0m\001]"
if (( USER_ID )); then
print -nr -- "[\001\e[1;36m\001$(id -un)\001\e[0m\001]\$"
else
print -nr -- "[\001\e[1;35m\001$(id -un)\001\e[0m\001]#"
fi
) '
… urgh, that’s colourful.
Have a lot of fun,
//mirabilos
--
"How can you ban language, words? How're words offensive? And why should I
have to tolerate YOUR interpretation? I'm the one using the word. ASK me how
I'm using it, don't TELL me. And if you don't like the way I'm using it, so
what? It's my right. It's my freedom of expression. Without that, we're
nothing but slaves." -- Johnny Rotten