Summary: | Up / down history damaged if last command output did not end in newline | ||
---|---|---|---|
Product: | [Applications] konsole | Reporter: | donquixote <py7smpbu> |
Component: | history | Assignee: | Konsole Developer <konsole-devel> |
Status: | RESOLVED NOT A BUG | ||
Severity: | normal | CC: | matan, ninjalj |
Priority: | NOR | ||
Version: | 21.12.3 | ||
Target Milestone: | --- | ||
Platform: | Ubuntu | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
donquixote
2023-01-16 17:12:39 UTC
Could also be a problem with bash or xterm. This seems to be my own problem, caused by a PS1 setting in .bashrc. So, probably not a problem of Konsole. Sorry for the noise! Actually no. After normalizing $PS1, I still see this problem occur. See also https://unix.stackexchange.com/questions/731987/terminal-history-up-down-broken-if-last-command-output-does-not-end-in-newline That's just bash (actually readline) thinking that the prompt starts at the leftmost position of the current line, then when you press Down, just moving to position 5, and clearing to the end of line. When you press Down, bash sends the following to the terminal: \r\33[C\33[C\33[C\33[C\33[K That's a carriage return to move to the leftmost position of the current line, four (the length of the prompt) CUF (Cursor Forward) control sequences, and an EL (Erase in Line) control sequence, which with parameter 0 (default) clears from the current cursor position to the end of the line. @ninjalj Thanks for the response in both places. I am not happy with this behavior of bash, but I don't really know where to take it from here. I don't know where I would file feature requests for bash. Perhaps I just need to find an alternative to bash. Add '\[\e]133;L\a\]' at the start of PS1. This is a conditional newline, so it does nothing if the previous output ended in newline, and a newline if the last output did not end in newline. > Add '\[\e]133;L\a\]' at the start of PS1. This is a conditional newline, so it does nothing if the previous output ended in newline, and a newline if the last output did not end in newline.
This sounds great, but it does nothing for me..
~ $ echo $PS1
\[\e]133;L\a\]\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;34m\]\w\[\033[00m\] \$
~ $ echo -n hello
hello~ $
~ $ export PS1="\[\e]133;L\a\] \$"
$ecoh^C
$export PS1="\[\e]133;L\a\] \$ "
$ echo -n hello
hello $
The "hello" is still always on the same line.
Btw, where could I look up these character sequences?
This person is asking for something similar, https://stackoverflow.com/questions/58626170/print-a-blank-line-in-bash-only-after-output (In reply to donquixote from comment #7) > > Add '\[\e]133;L\a\]' at the start of PS1. This is a conditional newline, so it does nothing if the previous output ended in newline, and a newline if the last output did not end in newline. > > This sounds great, but it does nothing for me.. > > ~ $ echo $PS1 > \[\e]133;L\a\]\[\e]0;\u@\h: This escape sequence is only supported since 22.08 (In reply to donquixote from comment #8) > This person is asking for something similar, > https://stackoverflow.com/questions/58626170/print-a-blank-line-in-bash-only- > after-output It is a feature that is easy to add to konsole, but currently there is nothing that does this. There are some options to make finding command start easier (separating line, alternating background). |