I think I found the source of this: byobu_prompt_runtime defined in 
/usr/share/byobu/profiles/bashrc outputs to stderr instead of stdout.
It could be fixed by modifying the function, or just adding 2>&1 to all calls:
# cp /usr/share/byobu/profiles/bashrc /usr/share/byobu/profiles/bashrc.bak
# sed -i 's/(byobu_prompt_runtime)/(byobu_prompt_runtime 2>\&1)/g' 
/usr/share/byobu/profiles/bashrc

Versions: bash 5.2.21-2ubuntu4, byobu 6.11-0ubuntu1, tmux 3.4-1ubuntu0.1

Reproduction:
- spin up new ubuntu:24.04 instance in e.g. incus
- make a non-root user, su to it, launch byobu
- get the prompt:
[0.002s] test@emerging-dassie:~$
- enter 32 characters (depends on length of hostname):
[2.201s] 130  test@emerging-dassie:~$ 12345678901234567890123456789012
- press ctrl-a/home and the cursor will be at the first "s", i.e. 8 characters 
have been cut off (the same length as "[2.201s]". Longer times result in more 
characters cut off)

- run a command, say ls, then press up until the long line has been reached
[38.581s] 130  test@emerging-dassie:~$ ls
[0.003s] test@emerging-dassie:~$ 12345678901234567890123456789012
- press down (don't press enter before)
[0.003s] test@emerging-dals

- the problem above is even worse with a short hostname
[0.003s] 1  test@test:~$ which ubuntu_prompt_status
[0.003s] 1  test@

- the problem is very evident when pasting commands, less so when typing
them.

Why does this happen? Inspecting PS1, we see calls to $(byobu_prompt_status), 
$(byobu_prompt_runtime), $(byobu_prompt_symbol).
[2.533s] 130  test@test:~$ byobu_prompt_status | wc -c
6
[0.004s] test@test:~$ byobu_prompt_symbol | wc -c
1
[0.004s] test@test:~$ byobu_prompt_runtime | wc -c
[0.001s]0

byobu_prompt_runtime is outputting to stderr instead of to stdout.
[0.004s] test@test:~$ byobu_prompt_runtime 2>&1 | wc -c
8

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2067490

Title:
  byobu prompt

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/byobu/+bug/2067490/+subscriptions


-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to