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

Re: OT: shell prompt tip



On Wed, Sep 13, 2000 at 11:57:20PM +0200, Julio Merino wrote:
> would you like to recognize fastly if you're a normal user or root?
> Change the default debian PS1 to something like this for your user:
> 
>     PS1='\[\e[22m\e[40m\e[32m\]\h:\w\$\[\e[22m\e[40m\e[37m\] '

My /etc/profile has the long line of:

test "$TERM" = "xterm" -o "$TERM" = "xterm-debian" && export PS1="\[\e]2;"`who
ami`"@"`hostname`"#"`tty`" ("`uname -sr`")\a\]\u@\h:\w\\$ " || export PS1="\u@
\h:\w\\$ "

All three lines should be concatenated and slapped in your /etc/profile or
~/.bash_profile as one big line for this to work.

This detects if you're on an xterm and sets the xterm's title bar to something
along the lines of 'piranha@omega#/dev/ttyp1 (Linux 2.2.16)' or 'piranha@zippy
#/dev/pts/11 (SunOS 5.7)'.  All information is autodetected as you set the
prompt, and little work must be done to use this trick on other Unices.  The
sheer length is a tad overkill, but it's customizable.  This is great for my
shell accounts on other systems; I can quickly glance to see who I am logged
in as, and where.  It uses xterm control codes to accomplish this.  I feel
it's better to put it in the prompt rather than using 'echo' in your
applicable 'profile'-file, since you can connect to another computer from your
xterm, and when you come back to your computer after you close the connection
or suspend telnet, the title bar is automatically changed as your local prompt
is displayed.  If you suspended a telnet session, going back into it restores
your title-bar text on the remote system (providing you hit enter to show the
prompt again).

My only problem is, when working in directories with a long line of
parent directories, the bash prompt becomes corrupt, often times beeping,
showing the last few characters of what's supposed to be the xterm title-bar
text, and as I type in commands, it just does erratic things to the echoing
of my typing, such as unpredictable newlines, etc.  Does bash has a maximum
effective prompt length?  If so, that'd probably be the case...  Any insight?

BTW, I'm *still* running slink.  (I know...)  'bash --version' reports:
version 2.01.1(1)-release (i486-pc-linux-gnu)

On an unrelated note, I'm *fairly* new to Linux (or UNIX in general), only
having been using it for about a year.  In the DOS command-interpreter 4DOS,
I could refer to parent directories as . and .. as is the norm in DOS and UNIX.
But I could also type, say, "cd ....", which would be equivalent of typing
"cd ..\..\..\".  It could be thought of as going up the directory tree, one dot
per level, the first representing the CWD.  Is there any practical way I could
make bash expand multiple dots like it would wildcards, passing the full
expanded form onto the program being called, without hacking up the source to
bash?

-- 
 J.P. Larocque, known online as piranha
 piranha@mindless.com
 Fidonet: prowler@1:346/6 (The Garage, 509-326-4609)

... Why buy her a Diamond when SHE doesn't last forever?



Reply to: