Long $ prompt

Gary W. Swearingen garys at opusnet.com
Tue Jun 20 18:26:17 UTC 2006


"OOzy Pal" <oozypal at gmail.com> writes:

> How can make ubuntu shows only the current directory and its parent
> only in Knosole i.e. if my pwd is
>
> ~/1/2/3/4/5/6/7/8$
>
> I'd like ubuntu to only show
>
> ~/7/8$

Here's something I once had working under some shell (ksh?) that
should give you a hint as to how to use awk which is pretty-much a
full programming language to manipulate data to you hearts content:


PS1="$(date | awk 'BEGIN { "id -un" | getline; name = $1; "pwd" | getline;
#  pwd = $1} {print "## " $4 " ## " name " @ " pwd " ## " $1 " " $3 "
" $2 " " $6 " " $5 "\n$ "}')"


My (two-line) prompt typically looks something like this:

## user1 ## 11:34:20 ## /etc/X11/xkb/symbols ## Sun Jun 18 ##
$  

That was produced on kubuntu/bash with

PS1='## \u ## \t ## $PWD ## \d ##\n$ '




More information about the ubuntu-users mailing list