WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Maximum length of 79 characters for PS1 prompt  (Read 2972 times)

Offline whoisterence

  • Newbie
  • *
  • Posts: 27
Maximum length of 79 characters for PS1 prompt
« on: January 23, 2013, 06:41:09 AM »
I am having trouble creating a PS1 prompt with complicated background and foreground colours.

But turns out if I set a really long PS1 like this one here, when I press ctrl+U to clear the prompt, the line above get erased?

PS1="12345678901234567890123456789012345678901234567890123456789012345678901234567890"

Is this because the terminal width is set to 80 somewhere?

I've tried different $TERM
rxvt, xterm-256color, etc..
same problem

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11629
Re: Maximum length of 79 characters for PS1 prompt
« Reply #1 on: January 23, 2013, 11:08:14 AM »
Hi whoisterence
I'm not sure I understand your question, but  Ctrl-u  cuts everything to the left of the cursor back to the
command prompt. When you enter something and it hits the right edge of the terminal, it wraps around to the
next visible line, but is still considered to be part of the same line.
If that does not answer your question, you might want to give a more precise example of what you are doing.

Offline whoisterence

  • Newbie
  • *
  • Posts: 27
Re: Maximum length of 79 characters for PS1 prompt
« Reply #2 on: January 23, 2013, 08:46:12 PM »
It's kinda hard to explain because it is counter intuitive, here is the reproducing sequence, paste this in aterm:

Code: (bash) [Select]
PS1="12345678901234567890123456789012345678901234567890123456789012345678901234567890"
ls -al
echo This line will be erased when you press Ctrl+U

Now, type some garbage and ctrl+U, the last line gets erased.

Turns out this only happens in aterm, if I load bash.tcz and use bash this doesn't happens.

Offline althalus

  • Sr. Member
  • ****
  • Posts: 351
Re: Maximum length of 79 characters for PS1 prompt
« Reply #3 on: January 23, 2013, 11:15:24 PM »
Slightly related question: Why on earth is your PS1 that long in the first place? That would get in the way of getting stuff done on any of the monitors I use...

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Maximum length of 79 characters for PS1 prompt
« Reply #4 on: January 23, 2013, 11:51:56 PM »
Is this because the terminal width is set to 80 somewhere?
You could test that with something like:
Code: [Select]
aterm -g 160x24
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline whoisterence

  • Newbie
  • *
  • Posts: 27
Re: Maximum length of 79 characters for PS1 prompt
« Reply #5 on: January 24, 2013, 02:07:46 AM »
@althalus
PS1 with path information can get quite long.

@tinypoodle
tested with wider aterm geometry e.g. 81x24 seems to fix it until I enlarge the terminal window, I think its because when I enlarge it, the text did not wrap around, but when I press Ctrl+U and it tries to calculate how many lines to remove.  Since the text is over the aterm defined width, the terminal believes it should have wrapped and therefore decides to remove one more line.

I guess the geometry is suppose to follow whatever the terminal window is, but doesn't?

Since this is just a nuances I am not sure if it's worth the effort to look deeper.  Especially since loading bash.tcz works as well.

Offline Akane

  • Jr. Member
  • **
  • Posts: 71
    • My home server by RaspberryPi
Re: Maximum length of 79 characters for PS1 prompt
« Reply #6 on: January 24, 2013, 02:11:50 AM »
I think it's a busybox's ash problem.
Maybe it doesn't recognize escape sequences and/or line length.

Please try the PS1 on bash if you want it.

Akane
Sorry for my terrible English.
Country: Japan
Interested in: HPC, low-level programming, embedded system and so on

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Maximum length of 79 characters for PS1 prompt
« Reply #7 on: January 24, 2013, 02:50:35 AM »
I guess the geometry is suppose to follow whatever the terminal window is, but doesn't?
Not clear what you mean by this, but I am under the impression it sounds kind of the wrong way round...
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline althalus

  • Sr. Member
  • ****
  • Posts: 351
Re: Maximum length of 79 characters for PS1 prompt
« Reply #8 on: January 24, 2013, 04:00:52 AM »
@althalus
PS1 with path information can get quite long.


Ah, running bash under cygwin on windows does some odd things like that too with crazy long paths. I generally avoid it by just showing the basename part of the path.