ubuntu terminal directory

Bill Bogstad bogstad-e+AXbWqSrlAAvxtiuMwx3w at public.gmane.org
Tue Mar 30 12:55:11 EDT 2010


On Tue, Mar 30, 2010 at 10:53 AM, j. daniel moylan
<moylan-HQzwBsY/FLGupFW5nWxcUQ at public.gmane.org> wrote:
> a few days ago derek martin gave the following as a prompt:
>
> PS1="\[\033]2;${chroot}\u@\h \W\007\][${chroot}\u@\h \w]\n\\$ "
>
> good stuff -- i always wanted to be able to put the current
> host into the title bar.  where can i read more about the
> protocol involved using brackets, octal numbers, etc.
>
> also, is there any way to get rid of the tilde at the
> beginning of \w?

It seems like the automatic substitution of tilde for your home
directory is baked into both the \w and \W substitutions for the PS1
variable.   You might want to look into the PROMPT_COMMAND variable
which causes bash to run any arbitrary command before the prompt is
displayed.  I believe you can dynamically change the PS1 variable
before every printing of your prompt using this mechanism.   Kind of
computationally expensive, but the ultimate in prompting flexibility.

You can learn more about this in the bash manual page in the section
on Shell Variables and also PROMPTING.  You can also read the bash
manual (probably via "info bash").   You may find that the bash manual
wasn't installed on your system by default.   On Ubuntu systems, you
need to install the bash-doc package.

Bill Bogstad






More information about the Discuss mailing list