[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to workaroun 'nl' being added to input-line after 49 characters.
From: |
Greg Wooledge |
Subject: |
Re: how to workaroun 'nl' being added to input-line after 49 characters.... |
Date: |
Mon, 14 Feb 2011 09:21:29 -0500 |
User-agent: |
Mutt/1.4.2.3i |
On Sun, Feb 13, 2011 at 08:17:05PM -0700, Bob Proulx wrote:
> _CRed=$(tput setaf 1) #Red
> _CRST=$(tput sgr0) #Reset
> _CBLD=$(tput bold) #Bold
> _prompt_open=""
> _prompt_close=""
> _prompt=">"
> [[ $UID -eq 0 ]] && {
> _prompt_open="$_CBLD$_CRed"
> _prompt_close="$_CRST"
> _prompt="#"
> }
> PS1='\[$_prompt_open\]$(pwd "$PWD")$_prompt\[$_prompt_close\] ';
This is the best one in the thread. Although I still don't see what
the $(pwd "$PWD") is supposed to mean....
Personally I would never use this much indirection in a PS1 assignment.
I appreciate that Bob was trying to maintain Linda's style -- it's that
style that I have a problem with. A lot of people think they can do
things like this:
f() { echo '\[blah blah\]'; }
g() { ...; }
h() { ...; }
PS1='$(f)$(g)$(h)'
That DOES NOT WORK. Don't even attempt it. You'll end up bald. The
\[ and \] have to be *literally* in the PS1 variable. They can't be
put there as a product of a substitution. (So then people think, "Oh,
then I need to use double quotes in the PS1 assignment..." and while
that technically *can* be made to work, it's abominable.)
If I were inclined to use garish colored prompts, my PS1 assignments
would look like this:
red=$(tput setaf 1) bold=$(tput bold) reset=$(tput sgr0)
PS1='\[$red\]\h\[$reset\]:\[$bold\]\w\[$reset\]\$ '
I tested that. It works.
However, I'm not so inclined. My PS1 actually looks like this:
PS1='\h:\w\$ '
That one has also been tested, and it also works. ;-)
- how to workaroun 'nl' being added to input-line after 49 characters...., Linda Walsh, 2011/02/13
- Re: how to workaroun 'nl' being added to input-line after 49 characters...., Bob Proulx, 2011/02/13
- Re: how to workaroun 'nl' being added to input-line after 49 characters...., Dennis Williamson, 2011/02/13
- Re: how to workaroun 'nl' being added to input-line after 49 characters...., Andreas Schwab, 2011/02/13
- Re: how to workaroun 'nl' being added to input-line after 49 characters...., Linda Walsh, 2011/02/13
- Re: how to workaroun 'nl' being added to input-line after 49 characters...., Bob Proulx, 2011/02/13
- Re: how to workaroun 'nl' being added to input-line after 49 characters...., Linda Walsh, 2011/02/13
- Re: how to workaroun 'nl' being added to input-line after 49 characters...., Bob Proulx, 2011/02/13
- Re: how to workaroun 'nl' being added to input-line after 49 characters....,
Greg Wooledge <=
- Re: how to workaroun 'nl' being added to input-line after 49 characters...., Bob Proulx, 2011/02/14
- Re: how to workaroun 'nl' being added to input-line after 49 characters...., Linda Walsh, 2011/02/14
- Re: how to workaroun 'nl' being added to input-line after 49 characters...., Linda Walsh, 2011/02/14
- Re: how to workaroun 'nl' being added: Working now! Tnx!, Linda Walsh, 2011/02/14
- Re: how to workaroun 'nl' being added to input-line after 49 characters...., Dennis Williamson, 2011/02/14
- Re: how to workaroun 'nl' being added to input-line after 49 characters...., Linda Walsh, 2011/02/14