vim-tmux-navigator icon indicating copy to clipboard operation
vim-tmux-navigator copied to clipboard

MacOS `Cmd + k` stopped working with the tmux plugin

Open osenvosem opened this issue 5 years ago • 8 comments

This keystroke is intended for clearing terminal buffer on MacOS.

MacOS 10.15.5 tmux 3.1b neovim 0.4.3 Alacritty 0.4.3

osenvosem avatar Jul 11 '20 14:07 osenvosem

The plugin should not have any effect on keybindings using Cmd unless you're using a non-standard setup. Also, just to confirm, the default configuration of the plugin does interfere with Ctrl-l for clear screen, but we have notes on restoring that functionality. Just wanted to highlight in case this is what you're referring to.

Otherwise, some additional questions to help figure this out:

  1. Are you a new user of the plugin and experiencing this with your first setup, or have you used the plugin before with success?
  2. Did this breakage come with an upgrade of any of the listed OS, tmux, or vim versions?
  3. Does this just "not work", or does it behave in an unexpected way?

christoomey avatar Jul 11 '20 14:07 christoomey

My setup is standard with no customizations related to the plugin. I refer specifically to Cmd + k because this is the main way to clear terminal on MacOS when you working with it.

  1. I experienced this issue every time I tried to use the plugin. There were a few times I tried it.
  2. No, I don't think so.
  3. Yes, the keystroke in tmux just stop working when I enable the plugin.

osenvosem avatar Jul 11 '20 15:07 osenvosem

By the way, this may be important, I use the Alacritty 0.4.3 terminal emulator.

osenvosem avatar Jul 11 '20 15:07 osenvosem

Cmd+K still switches splits instead of clearing terminal. Any plans to fix that?

osenvosem avatar Sep 30 '20 08:09 osenvosem

By the way, this may be important, I use the Alacritty 0.4.3 terminal emulator.

Hi @osenvosem I have noticed many things not working out-of-the-box myself with Alacritty; most noticeably this plugin. Although I'm not a Mac user, I believe issues like alacritty/alacritty#2204 are relevant to me and you. I've not gone to investigate much further that this.

dycw avatar Feb 25 '21 05:02 dycw

Is the -k key combo is defined via Alacritty by binding this to the usual Ctrl-k to clear end of the line ?

AxZxP avatar Jun 29 '22 17:06 AxZxP

I briefly investigated this issue on my Mac, I think the issue lies with

bind-key -n C-l   if-shell  "$is_vim"  "send-keys C-l"   "select-pane -R"

When you press cmd-k the terminal emulator remaps it to Ctrl+l command to the terminal. But Tmux with the config above captures it and interprets the command as select-pane to the right.

I have rebound my keyboard with Karabiner and use alacritty as my terminal emulator. Ideally alacritty could send a clear screen command another way instead of the rebinding, but I suspect that terminals take Ctrl+l to clear screen by default.

For now I'm content typing clear. Would love to hear other people's thoughts/work-arounds on this!

BhawickJain avatar Feb 20 '24 22:02 BhawickJain

So I have found a work around which isn't perfect like Ctrl+l. If you're using alacritty you can add a keyboard binding to send clear\n whenever you press cmd+k. Here is my alacritty.toml config snippet:

[keyboard]
bindings = [
{ key = "k", mods = "Command", chars = "clear -x\n" },
]

The -x flag ensures the history of window is still accessible if you scroll up [ref].

This workaround leaves a blank line at the top which is a little unflattering, but functionally it's good enough for me.

BhawickJain avatar Feb 20 '24 22:02 BhawickJain