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

Function Keys don't work in Byobu in bash for WSL #835

Closed
whackamus opened this issue Aug 18, 2016 · 24 comments
Closed

Function Keys don't work in Byobu in bash for WSL #835

whackamus opened this issue Aug 18, 2016 · 24 comments

Comments

@whackamus
Copy link

whackamus commented Aug 18, 2016

Versions

ConEmu build: 160724 x64
OS version: Windows 10 x64
Used shell version (Far Manager, git-bash, cmd, powershell, cygwin, whatever): Bash from Windows Subsystem for Linux

Problem description

This is a Windows Subsystem for Linux (WSL) bug, not a ConEmu bug. Byobu-specific function keys (e.g, F2 to open new window, F3 to cycle backward through open windows, F4 to cycle forward, etc.) do not work in ConEmu or in the Windows bash shell. Function keys do work in other bash applications (e.g., nano, htop). I'm hoping you can code a workaround like you did for cursor/arrow keys in WSL.

Steps to reproduce

  1. Open ConEmu with bash shell (C:\Windows\System32\bash.exe ~ -cur_console:p1)
  2. Launch byobu
  3. Press any function key

Actual results

Pressing F1-F4 doesn't do anything; pressing F5-F12 prints a tilde (~) to screen.

Expected results

F2 should create new bash instance inside of byobu. F3 should cycle backward through extant shells. F4 should cycle forward. F9 should launch byobu configuration.

Additional files

Settings,
screenshots,
logs,
etc.

@Maximus5
Copy link
Owner

Do F-keys work if you run WSL outside of ConEmu?
If they don't work - no workaround is possible.

@whackamus
Copy link
Author

F-keys work in WSL outside of ConEmu in apps other than byobu/tmux. F-keys work in WSL in ConEmu in apps other than byobu/tmux. It's only in byobu/tmux that they're broken. I know this isn't a ConEmu problem -- thanks for such amazing software, btw! -- but I'm hoping it's something that can be gotten around.

@hachre
Copy link

hachre commented Nov 7, 2016

It works for me usually when I start the bash process through ConEmu via bash -new_console:p:n.

However whenever the foreground process within byobu prints a lot of output it seems that me pressing F2 doesn't get through. It does work when I hammer it, but of course I usually open 20 shells extra then.

It does not seem to be a ConEmu-related problem though, as the same behavior is present by running bash via Windows' own cmd.

@skoshy
Copy link

skoshy commented Dec 6, 2016

This issue exists for me in ConEmu. Shift+any of the function keys do not work.

Specifically, I tried the following:

With Git Bash outside ConEmu

  • ssh'd into an Ubuntu server
  • ran byobu
  • Tried out the Shift+F2 "Vertical Split" hotkey, works great

With Git Bash inside ConEmu

  • ssh'd into an Ubuntu server
  • ran byobu
  • Tried out the Shift+F2 "Vertical Split" hotkey, does not work. It's ignored completely.

Any idea what could be causing this?

Another weird thing that I noticed is if I press F2 in ConEmu-GitBash, it outputs the letter B. In Regular GitBash, nothing happens. Shift+F2 produces ~ in ConEmu-GitBash, outputs the letter Q in Regular GitBash.

@Maximus5
Copy link
Owner

In the StatusBar there is "Terminal modes" column.
LClick on it, for WSL there must be "XTerm" option selected.
Also, there are two modes of keyboard encoding - try both of them by checking/unchecking AppKeys.

@t-anjan
Copy link

t-anjan commented Jan 11, 2017

@Maximus5 - XTerm is selected. Still, does not work with and without AppKeys selected.

Is there any solution to this problem?

I am using a vanilla install of Cmder (mini). Windows 10 with WSL installed. Using the following command to load bash in Cmder.

%windir%\system32\bash.exe ~ -c zsh -cur_console:p

To check if function keys work at all in the terminal window, I opened a text file with nano. With nano open, if I press F2 (the shortcut to save and close), it works as expected. So, the terminal receives at least F2 correctly.

Then, I opened byobu (installed by default in WSL / Ubuntu). Byobu opens correctly. But when I press F2, nothing happens. It is expected to open a new window within Byobu. Nothing even gets printed in the terminal.

Now, I am not sure if it is a ConEmu problem specifically. The exact same thing happens with the regular Windows cmd.exe . The difference is - if I LClick anywhere on the cmd terminal screen (activates select mode), and if I then press F2, it works by opening a new byobu window.

Not being able to use byobu makes the whole Windows Bash experience useless for me (especially when SSHing to remote machines). I would much appreciate a solution. Thanks!

Please let me know if this is not even a ConEmu problem and if I should post it somewhere else.

@Safrone
Copy link

Safrone commented Jan 25, 2017

I had issues with byobu on windows as well. Just pressing the function keys didn't do anything but holding them down caused it to occasionally actually see the input it seems.

@4rz0
Copy link

4rz0 commented Feb 20, 2017

Interesting, just hit the same error.
Holding the function keys in fact creates the expected results, but pressing them doesn't.
I'm not using ConEmu, tho.

@Morgy93
Copy link

Morgy93 commented Feb 28, 2017

Usually you're able to go through the windows with alt + left/right arrow keys but that also doesn't work.
But if you keep it pressed, then it will infinitely switch tabs. (So then it does work somehow..)

@sahil87
Copy link

sahil87 commented Apr 18, 2017

Facing the same issue. F6 prints the ~ character on the console.

@journey-of-code
Copy link

journey-of-code commented Nov 1, 2017

@Maximus5 : I tried all combinations of the terminal modes and they don't change the behavior.

  1. WSL Ubuntu Bash console (local) with byobu using three open terminals (no ConMemu): F-keys work all the time.
  2. WSL Ubuntu Bash console (local) with byobu using three open terminals (with ConEmu): F-keys occasionally work (every third time or so), otherwise the bell is invoked.

The bell (or sound) seems to be independent from the console as configuring it off (with set bell-style none) has no effect.

Environment:
ConEmu 161206 [64] {Stable} with a WSL (Windows Subsystem Linux) Ubuntu Bash shell.

Key-Events:
The tools mentioned here were not available through apt so I installed ncurses-examples (see here ) and used demo_altkeys to record the keys. I cleaned the output and added the pressed key like this: [key].

Keycode 265, name KEY_F(1) [F1]
Keycode 266, name KEY_F(2) [F2]
Keycode 267, name KEY_F(3) [F3]
Keycode 268, name KEY_F(4) [F4]
Keycode 269, name KEY_F(5) [F5]
Keycode 270, name KEY_F(6) [F6]
Keycode 271, name KEY_F(7) [F7]
Keycode 272, name KEY_F(8) [F8]
Keycode 273, name KEY_F(9) [F9]
Keycode 274, name KEY_F(10) [F10]
Keycode 275, name KEY_F(11) [F11]
Keycode 276, name KEY_F(12) [F12]
Keycode 558, name ESC-. [Alt+Right]
Keycode 543, name ESC-^_ [Alt+Left]
Keycode 564, name ESC-4 [Alt+Up] (was reported twice for one keystroke)
Keycode 523, name ESC-^K [Alt+Down]

@Maximus5
Copy link
Owner

Maximus5 commented Nov 1, 2017

  1. ConEmu build?
  2. Your task contents?
  3. https://conemu.github.io/en/KeyEvents.html

@journey-of-code
Copy link

@Maximus5 : I updated my comment. Could you explain what you mean by task contents?

@Maximus5
Copy link
Owner

Maximus5 commented Nov 1, 2017

How did you run your bash?
https://conemu.github.io/en/Tasks.html

From your keys log we can see that F-keys are received by your Unix console side properly. So the problem is not in ConEmu I believe.

Anyway, update to preview or alpha is recommended.

@journey-of-code
Copy link

journey-of-code commented Nov 1, 2017

Tried with alpha as well, same behavior.
Since this happens only in byobu/screen, I agree that there might be another cause for this behavior. Interestingly, a pure WSL bash session works correctly (and I guess that's why people brought up the issue here).
When I run a key-catching program like demo_altkeys, the reason for the different behavior can be observed. Running byobu/screen on
A) a WSL Ubuntu Bash
B) in ConEmu, WSL Ubuntu Bash
On A, the demo_altkeys never receives the F-keys. On B, it is a probabilistic event if byobu or the key-catcher consumes the event. Because both are separate processes, it looks like ConEmu is somehow interfering with at least one of the processes. Maybe this has something to do with the supervision of the processes? (ConEmu displays information about the processes for example)

@Maximus5
Copy link
Owner

Maximus5 commented Nov 1, 2017

Coz you didn't tell me about your bash task contents, I strongly recommend you to run ConEmu64.exe -basic -run {bash} using latest alpha vection.

@journey-of-code
Copy link

Same behavior when starting with ConEmu64.exe -basic -run {bash}.
My task for the console is {Bash::bash}. The associated command is set "PATH=%ConEmuBaseDirShort%\wsl;%PATH%" & %ConEmuBaseDirShort%\conemu-cyg-64.exe --wsl -cur_console:pm:/mnt

@ghost
Copy link

ghost commented Mar 2, 2018

I have a similar problem running cmd in ConEmu64 (180206 x64 on Windows 10 x64). On my laptop Fn+F8 should switch screens, but it has no effect if ConEmu has focus. KeyEvents reports this:

11:08:14 KEY_EVENT_RECORD: Dn, 1, Vk="VK_LWIN" [91/0x005B], Scan=0x005B uChar=[U=' ' (0x0000): A=' ' (0x00)]
         Ctrl=0x00000120 (casac - EcNs) (Windowed)
11:08:14 KEY_EVENT_RECORD: Up, 1, Vk="VK_P" [80/0x0050], Scan=0x0019 uChar=[U=' ' (0x0000): A=' ' (0x00)]
         Ctrl=0x00000020 (casac - ecNs) (Windowed)
11:08:14 KEY_EVENT_RECORD: Up, 1, Vk="VK_P" [80/0x0050], Scan=0x0019 uChar=[U=' ' (0x0000): A=' ' (0x00)]
         Ctrl=0x00000020 (casac - ecNs) (Windowed)
11:08:14 KEY_EVENT_RECORD: Up, 1, Vk="VK_LWIN" [91/0x005B], Scan=0x005B uChar=[U=' ' (0x0000): A=' ' (0x00)]
         Ctrl=0x00000120 (casac - EcNs) (Windowed)

The keys Fn+F1 (mute), Fn+F2 (volume down), Fn+F3 (volume up) work correctly, on the other hand. KeyEvents reports VK_VOLUME_MUTE, VK_VOLUME_DOWN, VK_VOLUME_UP, respectively.

@ghost
Copy link

ghost commented Mar 2, 2018

If I run KeyEvents in cmd.exe directly it looks slightly different (and the window switch is triggered as expected):

11:10:31 KEY_EVENT_RECORD: Dn, 1, Vk="VK_LWIN" [91/0x005B], Scan=0x005B uChar=[U=' ' (0x0000): A=' ' (0x00)]
         Ctrl=0x00000120 (casac - EcNs) (Windowed)
11:10:31 KEY_EVENT_RECORD: Up, 1, Vk="VK_P" [80/0x0050], Scan=0x0019 uChar=[U='p' (0x0070): A='p' (0x70)]
         Ctrl=0x00000020 (casac - ecNs) (Windowed)
11:10:31 KEY_EVENT_RECORD: Up, 1, Vk="VK_P" [80/0x0050], Scan=0x0019 uChar=[U='p' (0x0070): A='p' (0x70)]
         Ctrl=0x00000020 (casac - ecNs) (Windowed)

@Maximus5
Copy link
Owner

Maximus5 commented Mar 4, 2018

@cbuchacher Your cmd issue is offtopic here. This issue describes the problem of Windows Subsystem for Linux.

@Maximus5
Copy link
Owner

Maximus5 commented Mar 4, 2018

@journey-of-code Try to change TERM to xterm.

set "PATH=%ConEmuBaseDirShort%\wsl;%PATH%" & %ConEmuBaseDirShort%\conemu-cyg-64.exe -t xterm --wsl -cur_console:pm:/mnt

@Maximus5
Copy link
Owner

180416?

@Maximus5
Copy link
Owner

@steadfastgaze
Copy link

steadfastgaze commented Jan 7, 2021

For me the problem has been fixed using -new_console:p:n and wslbridge2

set "PATH=%ConEmuBaseDirShort%\wsl;%PATH%" & %ConEmuBaseDirShort%\conemu-cyg-64.exe %ConEmuBaseDirShort%\wsl\wslbridge2.exe -cur_console:pm:/mnt -eConEmuBuild -eConEmuPID -eConEmuServerPID -l -new_console:p:n

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests