You are not logged in.

#1 2014-01-31 11:13:47

edgley
Member
From: UK
Registered: 2011-07-06
Posts: 27
Website

[Solved] Erratic Shell Display and Command Behaviour

Hello!

This issue has bugged me for ages -- I've been using Arch for a pretty long time now, but I've just put up with it.

Basically, when I scroll back through my bash history, one of my previous commands will arbitrarily appear partially entered while also shifting my cursor (usually to the end of the partial command but sometimes further). If I then continue to scroll, that partial command will remain in place.

However, executing a new command will work as if the previous one was not there.

eg:
2v95ill.png

So I simply ran:

dig elexs.org
echo "test"

But before the echo, I scrolled back. Looking at what is entered on the command, you'd expect it to have run a dig elexs.oecho and tried to look up the "test" records.

Also, I suspect this is related, when going back to the start of the command (with Home etc), the cursor will sometimes decide to only go part way, but when pressing Delete, will actually delete from the start of the command.

eg:
rr2ft3.png

Again, I ran:

echo "this is a longer command"
cho "this is a longer command"
echo "this is a longer command1"

But there is an obvious disparity with what is being displayed in my terminal and what is actually being executed.

As I say, this issue has been apparent for a long time, and as far as I am aware, since I started using Arch a few years ago. It affects all computers I've installed Arch on, with all sorts of setups, Intel / AMD / nVidia graphics etc.

I've also checked and both issues occurs in TTY's and SSH sessions to other Arch desktops for me as well.

What is potentially revealing is, when SSH'ing into any of my CentOS 5/6 servers, the issue is not present. The same is also true when SSH'ing into an Arch VPS I have, that was built using a stock image the VPS had.

I initially though this may be a PS1 issue or bashrc related, but as my VPS (which definitely doesn't have the issue) uses the same .bashrc as my desktops, I'm reluctant to think that any more.

For the record, my .bashrc is:

[[ $- != *i* ]] && return
set -o posix
complete -cf sudo
export EDITOR=vim
export LANG="en_GB.UTF-8"
export PATH="/bin:/usr/bin:~/bin"

alias scrot='scrot -c -d 3 -q 100'
alias l='ls -hl --color=always'
alias ll='ls -hla --color=always'
alias grep='grep --color=always'
alias dmesg='dmesg --color'
alias vim='vim -p'
alias ..='cd ..'
alias ~='cd ~'
alias xterm='xterm -rv'

PS1="[\e[0;33m\W\033[0m]$ "

Any help would be appreciated as always; while I'll be kicking myself if it's simple, it would also be a great relief.

Thanks,
e

Last edited by edgley (2014-01-31 20:19:43)

Offline

#2 2014-01-31 12:06:37

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,652
Website

Re: [Solved] Erratic Shell Display and Command Behaviour

You need to enclose the color codes in your prompt in \[ \] pairs for readline to know not to count those characters.

For example:

PS1="[\[\e[0;33m\]\W\[\033[0m\]]$ "

Last edited by Trilby (2014-01-31 12:07:57)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2014-01-31 12:28:06

edgley
Member
From: UK
Registered: 2011-07-06
Posts: 27
Website

Re: [Solved] Erratic Shell Display and Command Behaviour

Hi Trilby,

Thanks for the reply! That makes sense and it appears to be working; I'll make the change across my desktops and hope it does the job (I'll update the title of this thread tonight if it all good).

Any ideas why this wouldn't affect my VPS though? As I say, I used the same wonky PS1 there, but I've never had the issue...

Offline

#4 2014-01-31 20:19:30

edgley
Member
From: UK
Registered: 2011-07-06
Posts: 27
Website

Re: [Solved] Erratic Shell Display and Command Behaviour

Just to say, seems like that was the fix -- can't believe I'd been putting up with it for so long!

Thanks again, will mark this as solved.

Offline

Board footer

Powered by FluxBB