添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

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

Using alacritty (downloaded from the appveyor link) on windows and have some issues/questions about key bindings.

  • bash shortcuts using Alt key are not working - is this expected?
    I added a few mappings to the config file that gets me some of what I most commonly use, but however I still miss several other important ones that I don't know how to map ( Alt+. for instance, and others).
    Should this work out of the box, or if not, can a canned list of such mappings be made available for those who might want to add it to their configs optionally.
    One I sorely miss and don't know how to map is Ctrl+Alt+e which binds to expanding aliases.
  •   - { key: D,        mods: Alt,     chars: "\x1bd"                       }
      - { key: B,        mods: Alt,     chars: "\x1bb"                       }
      - { key: F,        mods: Alt,     chars: "\x1bf"                       }
    
  • In tmux I use Space as my prefix key.
    set -g prefix C-Space
    I've tried different things (blindly) in the config file and couldn't get this to work.
    Any pointers on how to achieve this mapping?
  • Off topic, but on windows, alacritty doesn't honor any of the command line arguments for me. I've seen other folks refer to using this even on windows, so somehow it is specific to my setup I assume. i.e. if I run alacritty.exe -vvv it spawns the terminal but there is no debug output, or if I do alacritty.exe --help the command just returns without any output.

    Thanks!

    Thanks!

    Regarding the console output are you using a build from a7e59d39 or later? There was a change made which should fix console output.

    Keybindings are not something I've tested much. I don't know how 'special' actions like expanding aliases are triggered.

    It's possible that this might need to wait for #1661, because currently all input to Alacritty has to pass through:

    Alacritty => WinPTY => CONHOST(cmd) => Shell(User specified)

    And if any part of that chain doesn't understand the input it'll probably just get dropped (CONHOST being the worst offender).

    I'd suggest trying these things in a bare wsl prompt to see if they work first, then we can go from there.

    Not being able to map Control+Space kills me as that's my tmux prefix, and I just cannot get it to work (even in bare wsl). Not sure if this is Windows specific, or if I am just not setting up the mapping correctly. I've tried this to no avail:
    - { key: Space, mods: Control, chars: "\x00" }

    I managed to get Alt+. working using the mapping:
    - { key: Period, mods: Alt, chars: "\x1b." }

    BTW, I moved up to the latest rev from Appveyor and that resolved the console output issue! Thanks again.

    Found a few past references to using Ctrl+Space, most of them duped to #99, however the popular solution referenced in there doesn't work for me on Windows, it's the one I referenced above, but I'll include the mapping below again.
    - { key: Space, mods: Control, chars: "\x00" }

    Not sure if this is Windows specific or my setup specific. Would be great if someone can test this out in their setup..

    If you can't get it to work in bare wsl it's extremely unlikely we'll be able to solve it in alacritty (Might be worth creating an issue in Microsoft/console).

    You're welcome to keep investigating this but I'm probably not going to give it much attention anytime soon.

    Not sure if it's related, but Alt Gr is not working in Alacritty (eg. can't type @ on Azerty)
    Works fine in other terminals

    If you can't get it to work in bare wsl it's extremely unlikely we'll be able to solve it in alacritty

    I can confirm that this works as expected in cmd and powershell running wsl. i.e. I'm able to set C-Space as my tmux prefix key and it works without any issues.

    I assume this is what you were referring to when you say "bare wsl"?

    Seems specific to Windows alacritty given #99 seems to resolve for other platform(s).
    FWIW, pretty easy to repro in a couple of steps:

  • run tmux in bash
  • set prefix by doing: tmux set -g prefix C-Space
  • now type C-space followed by % - this if it works successfully will split the terminal into two vertical panes, otherwise it would enter the % or Space character literally as it does on Windows alacritty.
  • Ran with --print-events to see what the key press events captured by alacritty.
    Looks like alacritty is picking up the key presses fine but they're potentially getting dropped on the floor somewhere without getting passed on to bash/tmux?
    Either that, or the mapping in alacritty.yml is not correct/working.

    glutin event: DeviceEvent { device_id: DeviceId(DeviceId(462556243)), event: Key(KeyboardInput { scancode: 29, state: Pressed, virtual_keycode: Some(LControl), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } }) }
    glutin event: WindowEvent { window_id: WindowId(WindowId(0x12d0f6e)), event: KeyboardInput { device_id: DeviceId(DeviceId(0)), input: KeyboardInput { scancode: 29, state: Pressed, virtual_keycode: Some(LControl), modifiers: ModifiersState { shift: false, ctrl: true, alt: false, logo: false } } } }
    glutin event: DeviceEvent { device_id: DeviceId(DeviceId(462556243)), event: Key(KeyboardInput { scancode: 57, state: Pressed, virtual_keycode: Some(Space), modifiers: ModifiersState { shift: false, ctrl: true, alt: false, logo: false } }) }
    glutin event: WindowEvent { window_id: WindowId(WindowId(0x12d0f6e)), event: KeyboardInput { device_id: DeviceId(DeviceId(0)), input: KeyboardInput { scancode: 57, state: Pressed, virtual_keycode: Some(Space), modifiers: ModifiersState { shift: false, ctrl: true, alt: false, logo: false } } } }
    glutin event: WindowEvent { window_id: WindowId(WindowId(0x12d0f6e)), event: ReceivedCharacter(' ') }
    glutin event: Awakened
    glutin event: DeviceEvent { device_id: DeviceId(DeviceId(462556243)), event: Key(KeyboardInput { scancode: 57, state: Released, virtual_keycode: Some(Space), modifiers: ModifiersState { shift: false, ctrl: true, alt: false, logo: false } }) }
    glutin event: WindowEvent { window_id: WindowId(WindowId(0x12d0f6e)), event: KeyboardInput { device_id: DeviceId(DeviceId(0)), input: KeyboardInput { scancode: 57, state: Released, virtual_keycode: Some(Space), modifiers: ModifiersState { shift: false, ctrl: true, alt: false, logo: false } } } }
    glutin event: DeviceEvent { device_id: DeviceId(DeviceId(462556243)), event: Key(KeyboardInput { scancode: 29, state: Released, virtual_keycode: Some(LControl), modifiers: ModifiersState { shift: false, ctrl: true, alt: false, logo: false } }) }
    glutin event: WindowEvent { window_id: WindowId(WindowId(0x12d0f6e)), event: KeyboardInput { device_id: DeviceId(DeviceId(0)), input: KeyboardInput { scancode: 29, state: Released, virtual_ke
              

    @damnskippy Did you ever happen to solve this issue? Currently having the same problem (but trying to use ctrl+space in Vim rather than in tmux). I see the Ubuntu WSL app handles Ctrl+space fine, as well as WSLtty, but sadly no luck in Ubuntu. Temporary fix for me will be to remap my Ctrl+space in Windows to something else (thankfully I don't use Ctrl+space for much) but far from ideal.

    #1703 (comment)
    User damnskippy's comment above worked for me with Alacritty on Win10. In case it's relevant, I'm launching Alacritty into WSL with

    shell:
      program: bash
      args:
        - -c tmux
    

    For the lazy, damnskippy's fix was this: - { key: Space, mods: Control, chars: "\x00" }

    I also see some mentions of configuring tmux like

    set -g prefix C-Space
    unbind C-Space
    bind C-Space send-prefix
    

    That middle "unbind" line is new to me, and may or may not be important for your setup.

    Just in case there's some other mystery config I have interacting with this that I'm not aware of, all my configs are here: https://github.com/Akaito/configfiles

    Today I changed my shell on a remote server to ZSH (probably not related but that was the last thing I did) and my Control-Space binding completely stopped working. I tried to apply damnskippy's fix but to no avail. In fact, it would seem that Alacritty is not detecting anything when I press Control-Space. I can change the chars in that fix to any sequence of characters, but no matter what I do, pressing Control-Space just yields ^\ in the terminal.

    I have alacritty running with shell.program: wsl. The keybinding works with no issues or configuration whatsoever when I try it in the default WSL terminal.

    I cannot run alacritty --print-events as it errors out with Failed to initalize any backend!.

    I am truly at a loss as to how this started happening, but I can provide any relevant info if needed.

    If Alacritty's output contains ReceivedCharacter('\u{0}') when running alacritty --print-events | grep "ReceivedCharacter", then this is a Windows bug.

    If it doesn't contain that for you, please let me know.

    If I bind C-Space to send "\x00", it not work:

    D:\>xxd -psd
    a        # press ctrl-space, a, enter
    610d0a
    

    But if I bind C-Space to send "\x02" (i.e. C-b), it works:

    D:\>xxd -psd
    ^Ba      # press ctrl-space, a, enter
    02610d0a
    

    A workaround for tmux: use C-b as tmux's prefix key and bind C-Space to "\x02" in alacritty.

    @chris-morgan @ShalokShalom It is actually just printing a space, and I also have the same logs.

    What do I have to do with it?

    Reporting same issue and resolution with C-SPC on Win 10 using Alacritty 0.6.0 from Choco. Unable to use C-SPC on terminal Emacs until adding the keybind
    - { key: Space, mods: Control, chars: "\x00" }
    Without that, emacs got only a space character. I was able to correctly use C-SPC talking to the same terminal Emacs session (shared in tmux) using Windows Terminal and also using Powershell console window. Also able to do so from another machine, although that was likely not in doubt.

    Unfortunately, all above solutions doesn't work from my side. But I finnally find this is caused by a bug of openssh-windows client. microsoft/terminal#2865 (comment)

    I managed to build openssh-windows with this fix. Now alacritty and windows terminal can send "ctrl - space" through ssh.exe to remote server ("Ctrl+Space" prefix in tmux works as expected)

    prefix setting in tmux

    set -g prefix C-Space
    unbind C-Space
    bind C-Space send-prefix
    

    don't forget to add below config to alacritty.yaml file at first. Otherwise above fix won't work for alacritty.

    - { key: Space, mods: Control, chars: "\x00" }

    Just to be clear, the advertised - { key: Space, mods: Control, chars: "\x00" } solution should go as the following in alacritty.yml:

    key_bindings:
        - { key: Space, mods: Control, chars: "\x00" }
      thekaganugur, niixtek, ddesvillechabrol, ntananh, cscherrNT, antoson, liambutterworth, serranomorante, rafa-thayto, and Kiyoponn reacted with heart emoji
      rafa-thayto reacted with rocket emoji
          All reactions
    

    Just to be clear, the advertised - { key: Space, mods: Control, chars: "\x00" } solution should go as the following in alacritty.yml:

    key_bindings:
        - { key: Space, mods: Control, chars: "\x00" }
    

    Your comment just saved my life.

    Just to be clear, the advertised - { key: Space, mods: Control, chars: "\x00" } solution should go as the following in alacritty.yml:

    key_bindings:
        - { key: Space, mods: Control, chars: "\x00" }
    

    Thank you so much!

    Unfortunately, all above solutions doesn't work from my side. But I finnally find this is caused by a bug of openssh-windows client. microsoft/terminal#2865 (comment)

    I managed to build openssh-windows with this fix. Now alacritty and windows terminal can send "ctrl - space" through ssh.exe to remote server ("Ctrl+Space" prefix in tmux works as expected)

    Another way to get a working ssh on Windows (if you don't want to rely on MS's OpenSSH port) is to use the MSYS2 ssh, which most users likely already have: it's distributed alongside Git for Windows in C:\Program Files\Git\usr\bin. The MSYS2 port is nice because it's pretty much the same SSH as you'd get on Linux, so it's battle-tested. While I appreciate that MS is trying to provide nice things like a native OpenSSH port, it's just not reliable enough (yet).

    I've been using that with the recent change to support newer conpty.dll versions, and it works perfectly as far as I can tell. (At least on Windows 10, you really need the conpty.dll fix to do it this way. Without it, I got extraneous \ characters in my terminal.)

    @jimporter - appreciate your your build of alacritty ( cmentioned in #6994 ) - couldnt get the \ chars removed (on my win10 system) using any conpty i found in the wild. Looks like it'll be posted in to https://www.nuget.org/packages?q=conpty at some point in the future so I'll keep waiting and using putty instead.

    The keybind did work in good ol emacs using git-ssh but not ms's built in agent

    @jimporter - appreciate your your build of alacritty ( cmentioned in #6994 ) - couldnt get the \ chars removed (on my win10 system) using any conpty i found in the wild. Looks like it'll be posted in to https://www.nuget.org/packages?q=conpty at some point in the future so I'll keep waiting and using putty instead.

    I just used the openconsole.exe and conpty.dll from WezTerm's Windows builds: https://wezfurlong.org/wezterm/install/windows.html, and it worked ok for me.

    @jimporter - appreciate your your build of alacritty ( cmentioned in #6994 ) - couldnt get the \ chars removed (on my win10 system) using any conpty i found in the wild. Looks like it'll be posted in to https://www.nuget.org/packages?q=conpty at some point in the future so I'll keep waiting and using putty instead.

    I just used the openconsole.exe and conpty.dll from WezTerm's Windows builds: https://wezfurlong.org/wezterm/install/windows.html, and it worked ok for me.

    Thanks! i did not realize that openconsole.exe was also needed; dropped it and conpty.dll side by side with the alacritty.exe build and the ctrl+space is working and no funky \ chars. Also thanks for the wezterm url!

    @jimporter - appreciate your your build of alacritty ( cmentioned in #6994 ) - couldnt get the \ chars removed (on my win10 system) using any conpty i found in the wild. Looks like it'll be posted in to https://www.nuget.org/packages?q=conpty at some point in the future so I'll keep waiting and using putty instead.

    I just used the openconsole.exe and conpty.dll from WezTerm's Windows builds: https://wezfurlong.org/wezterm/install/windows.html, and it worked ok for me.

    Thanks! i did not realize that openconsole.exe was also needed; dropped it and conpty.dll side by side with the alacritty.exe build and the ctrl+space is working and no funky \ chars. Also thanks for the wezterm url!

    With this advice, together with updating OpenSSH version for Windows as instructed here - https://github.com/PowerShell/Win32-OpenSSH/wiki/Install-Win32-OpenSSH - I managed to finally get "CTRL+Space" to work even over SSH, together with mouse event forwarding.

    So it would be nice to update in the readme the following steps for getting it to work (summarizing everyone up):
    0. Get the latest dev Alacritty version

  • Copy the both "conpty.dll" and "OpenConsole.exe" from https://github.com/wez/wezterm/tree/main/assets/windows/conhost to Alacritty binaries dir
  • Update OpenSSH to version >= 8.9 either by having "Windows Insider Builds" or by winget as in https://github.com/PowerShell/Win32-OpenSSH/wiki/Install-Win32-OpenSSH
  • Configure - { key: Space, mods: Control, chars: "\x00" } under key_bindings configurations of Alacritty
  • Didn't open the issue by myself, but this steps fully closes the issue.