Long $ prompt - A working (short) solution
Erik Christiansen
erik at dd.nec.com.au
Wed Jun 21 02:43:29 UTC 2006
On Tue, Jun 20, 2006 at 11:26:17AM -0700, Gary W. Swearingen wrote:
>
> 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 ##
Gary, you've prompted me to spend a minute to bang thick rust off last
century's gleaming awk skills, to hack:
PS1="$(pwd | awk -v FS='/' '{print "+/" $(NF-1) "/" $NF ": "}')"
This produces a slightly (to my eye) enhanced version of the prompt that
OOzy requested:
+/sli_16/src: pwd # The prompt is cwd and its parent.
/home/erik/projects/sli_16/src
The "+" is better than ".." for obvious reasons, and shorter than "..."
There's a space following ":"
OOzy, I'm sure that you'll be able to edit out any parts of the new
prompt which you consider a waste of space. :-)
Happy hacking,
Erik
--
Unix is userfriendly, it's just picky about who its friends are.
More information about the ubuntu-users
mailing list