At date and time Fri, 7 Nov 2014 16:17:04 +0000 (UTC), Thorsten Glaser wrote:
> 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 b bracketingb 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 b p=~b .
>
> >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)b &
>
>
> 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
> ) '
That is fantastic! I would never have solved it myself. Thank you!
> b & urgh, thatb s colourful.
haha! Yes but it gives me an instant visual cue concerning path, user,
and host. Thank you again: that is service beyond the call of duty!
;-)
--
Gerard Lally