Odd result of terminal history with up arrow (Solved)

Post here if you feel others can duplicate your so discovered "bug"

Moderator: Forum moderators

Post Reply
d-pupp
Posts: 183
Joined: Tue Nov 22, 2022 9:11 pm
Location: Canada
Has thanked: 90 times
Been thanked: 40 times

Odd result of terminal history with up arrow (Solved)

Post by d-pupp »

From the Linux Mint forum

When I use the up arrow in a terminal to scroll through the history, I get some strange results.

If the commands in my history have been short commands, there's no problem. When I get to one that was kind of long, then the next time I hit the up arrow, the first ten or twelve characters of the long command get stuck after the cursor.

Looks like this problem is related to my use of a personalized color prompt

I had this same problem
Old prompt string

Code: Select all

PS1="\[\e]2;\w\a\e[92m\]\W \\[\e[0m\]\e[93m\]\\$ \e[0m\]"

New prompt string Deleted

When I changed from the double quote to single the missing bracket showed up but the problem with my history seems to be the double \\$ as \$ works fine

Edit @Burunduk Thank you your code works mine didn't on longer history commands.
The correct prompt string is Burunduk

Last edited by d-pupp on Mon May 15, 2023 3:39 pm, edited 1 time in total.
User avatar
bigpup
Moderator
Posts: 6271
Joined: Tue Jul 14, 2020 11:19 pm
Location: Earth, South Eastern U.S.
Has thanked: 732 times
Been thanked: 1292 times

Re: Odd result of terminal history with up arrow (Solved)

Post by bigpup »

Which specific terminal?

Exactly where does this code change go?

Forum Global Moderator
The things you do not tell us, are usually the clue to fixing the problem.
When I was a kid, I wanted to be older.
This is not what I expected :o

Burunduk
Posts: 244
Joined: Thu Jun 16, 2022 6:16 pm
Has thanked: 6 times
Been thanked: 122 times

Re: Odd result of terminal history with up arrow (Solved)

Post by Burunduk »

bigpup wrote: Mon May 15, 2023 12:53 am

Exactly where does this code change go?

Usually into /root/.bashrc. All the explanations are here.

Both examples are problematic. The former has \\[ instead of \[ in the middle and both have an unmatched \] bracket at the end. The latter makes bash to output ~ 0m# as a prompt (in urxvt on Fossapup64) and the length of the prompt is still miscalculated.

To get the colored ~ # prompt:

Code: Select all

PS1="\[\e]2;\w\a\e[92m\]\W \[\e[93m\]\\$ \[\e[0m\]"
# or in single quotes
PS1='\[\e]2;\w\a\e[92m\]\W \[\e[93m\]\$ \[\e[0m\]'

Notes: "\\$" and '\$' are equivalent.
To change the color, there is no need to reset it.

Edit: @d-pupp : With your prompt, the LXTerminal in Vanilla Dpup doesn't output 0m but the length calculation is still wrong. You can see it by typing a command that is wider than the terminal window. By the way, I think the default prompt there is a disaster. It lies like a gas meter (if there is such a saying).

User avatar
Marv
Posts: 384
Joined: Fri Dec 20, 2019 3:09 am
Has thanked: 181 times
Been thanked: 103 times

Re: Odd result of terminal history with up arrow (Solved)

Post by Marv »

Burunduk wrote: Mon May 15, 2023 3:35 am
bigpup wrote: Mon May 15, 2023 12:53 am

Exactly where does this code change go?

Usually into /root/.bashrc. All the explanations are here.

In several of the 'newer pups, F96-CE, another jammypup64, Bookworm Pup64 for example, /etc/profile is included in /root/.bashrc (by . /etc/profile) so the PS1= code is found in /etc/profile or in the case of jammypup64, in /etc/profile.d/ps1.sh, which is included in /etc/profile. Don't shoot me, just the messenger :roll: Great link to the formatting explanation. Thanks

My pups: LxPupSc64 and Voidpup64 with LXDE ydrv & synaptics touchpad drivers, both using savefiles. Ydrv based Jammypup64 (JWM), Bookworm64, Fossapup23 & FossapupFire (LXDE/PCManFM). No savefiles, no fdrvs there. :thumbup:

d-pupp
Posts: 183
Joined: Tue Nov 22, 2022 9:11 pm
Location: Canada
Has thanked: 90 times
Been thanked: 40 times

Re: Odd result of terminal history with up arrow (Solved)

Post by d-pupp »

@bigpup Marv is correct /etc/profile.
You can also use your home directory and put it in .bashrc ie. /root/.bashrc
This will override the one in /etc/profile

Post Reply

Return to “Bug Reports”