Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Being in a toolbox breaks Ctrl-p for readline #394

Closed
srbaker opened this issue Mar 26, 2020 · 2 comments · Fixed by #518
Closed

Being in a toolbox breaks Ctrl-p for readline #394

srbaker opened this issue Mar 26, 2020 · 2 comments · Fixed by #518
Labels
1. Bug Something isn't working

Comments

@srbaker
Copy link

srbaker commented Mar 26, 2020

I use the readline commands for navigating my command history in bash. That is: C-p for previous, C-n for next. C-p should do the same thing as up-arrow, and C-n should do the same as down-arrow.

When I am in a toolbox and I press C-p to get my previous command, nothing shows up. If I press return, the command shows up, and executes, but it was not visible until I press return. If I press C-p twice, I see the two-commands-ago command line, and then pressing C-n gives me the previous command.

This only happens when I am inside a toolbox on Fedora Silverblue. I have not tried it on other platforms. It does not happen on the same machine, when I am not in a toolbox.

up-arrow and down-arrow work just fine.

@srbaker
Copy link
Author

srbaker commented Mar 26, 2020

Sorry, a detail I forgot to mention: pressing C-p repeatedly, only every other press works.

If I have the following command history:

echo foo
echo bar
echo baz
echo qux

The following sequences happen:
C-p shows me nothing. Pressing return runs echo qux

C-p C-p shows echo baz. Then C-n will show echo qux.

C-p C-p C-p shows echo baz, but pressing return changes it to echo bar and runs that.

@EnigmaCurry
Copy link
Contributor

I've been researching this myself and I know how to fix it.

Podman has a feature called detaching that listens for a key sequence and then detaches the tty from the running container. By default, that key sequence is "ctrl-p, ctrl-q". The problem has been that there was no way to turn this feature off (the best you could do was assign a different key sequence, but not turn if off entirely.)

This is a bug fixed in podman 1.8.2 : containers/podman#5203 - you can now set the key sequence to the empty string (--detach-keys="") and this will completely disable the detach feature.

Toolbox needs a change to specify the detach-keys for podman. Here is my fork that is tested working, but it could likely be made more robust/configurable. EnigmaCurry@2baf60f

I will look into what it takes to open a PR for this...

@HarryMichal HarryMichal added the 1. Bug Something isn't working label Jul 28, 2020
HarryMichal pushed a commit to HarryMichal/toolbox that referenced this issue Jul 28, 2020
Podman sets keys 'ctrl-p' and 'ctrl-q' as the default detach keys. This
behaviour is not desirable in Toolbox. Since Podman v1.8.2[0] it is
possible to have set no detach keys by passing an empty string to the
--detach-keys option.

Thanks to this the 'Ctrl+p' and 'Ctrl-q' combinations are doing what
they should do normally in a terminal.

[0] containers/podman#5203

Fixes: containers#394

containers#396
HarryMichal pushed a commit to HarryMichal/toolbox that referenced this issue Jul 28, 2020
Podman sets keys 'ctrl-p' and 'ctrl-q' as the default detach keys. This
behaviour is not desirable in Toolbox. Since Podman v1.8.2[0] it is
possible to have set no detach keys by passing an empty string to the
--detach-keys option.

Thanks to this the 'Ctrl+p' and 'Ctrl-q' combinations are doing what
they should do normally in a terminal.

[0] containers/podman#5203

Fixes: containers#394

containers#396
HarryMichal pushed a commit to HarryMichal/toolbox that referenced this issue Jul 28, 2020
Podman sets keys 'ctrl-p' and 'ctrl-q' as the default detach keys. This
behaviour is not desirable in Toolbox. Since Podman v1.8.2[0] it is
possible to have set no detach keys by passing an empty string to the
--detach-keys option.

Thanks to this the 'Ctrl+p' and 'Ctrl-q' combinations are doing what
they should do normally in a terminal.

[0] containers/podman#5203

Fixes: containers#394

containers#396
debarshiray pushed a commit to HarryMichal/toolbox that referenced this issue Sep 2, 2020
Podman sets 'ctrl-p ctrl-q' as the default key sequence for detaching
a container. This breaks the ctrl-p shortcut that's equivalent to the
up arrow key in GNU Readline environments like Bash and Emacs.
Moreoever, toolbox containers aren't meant to be detached in the first
place.

Since Podman 1.8.1, it is now possible to unset the key sequence for
detaching [2, 3].

[0] https://tiswww.cwru.edu/php/chet/readline/readline.html#SEC15

[1] https://www.gnu.org/software/emacs/tour/

[2] Podman commit 7c623bd41ff3d534
    containers/podman#4208

[3] Podman commit ebfd253fc658ffc9
    containers/podman#5166

containers#394
likan999 pushed a commit to likan999/ppa-toolbox that referenced this issue Oct 30, 2020
Podman sets 'ctrl-p ctrl-q' as the default key sequence for detaching
a container. This breaks the ctrl-p shortcut that's equivalent to the
up arrow key in GNU Readline environments like Bash and Emacs.
Moreoever, toolbox containers aren't meant to be detached in the first
place.

Since Podman 1.8.1, it is now possible to unset the key sequence for
detaching [2, 3].

[0] https://tiswww.cwru.edu/php/chet/readline/readline.html#SEC15

[1] https://www.gnu.org/software/emacs/tour/

[2] Podman commit 7c623bd41ff3d534
    containers/podman#4208

[3] Podman commit ebfd253fc658ffc9
    containers/podman#5166

containers#394
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1. Bug Something isn't working
Projects
None yet
3 participants