Skip to content

Unable to override SHIFT-CMD-[ and SHIFT-CMD-] #6616

Open
@alberti42

Description

What Operating System(s) are you seeing this problem on?

macOS

Which Wayland compositor or X11 Window manager(s) are you using?

MacOS Sequoia

WezTerm version

wezterm 20240203-110809-5046fc22

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

Yes, and I updated the version box above to show the version of the nightly that I tried

Describe the bug

Most likely I am doing some dummy mistake. In my configuration file I have a quite a few key bindings working. However, I was not able to override WezTerm default behavior when pressing CMD-SHIFT-[ and CMD-SHIFT-]. Below are just two of the recent attempts.

{ key = '[', mods = 'SHIFT | SUPER', action = wezterm.action { SendString = '\x02p' } }, -- Cmd + Shift + [ -> Move to previous tmux pane
{ key = ']', mods = 'SHIFT | SUPER', action = wezterm.action { SendString = '\x02n' } }, -- Cmd + Shift + ] -> Move to next tmux pane

{ key = '{', mods = 'SUPER', action = wezterm.action { SendString = '\x02p' } }, -- Cmd + Shift + [ -> Move to previous tmux pane
{ key = '}', mods = 'SUPER', action = wezterm.action { SendString = '\x02n' } }, -- Cmd + Shift + ] -> Move to next tmux pane

It works if I omit SHIFT or for example I replace SHIFT with CTRL. But ideally I would like to bind CMD-SHIFT and not CMD-CTRL.

If you have any idea what I am doing wrong or if this could be a bug, let me know.

To Reproduce

No response

Configuration

-- ~/.wezterm.lua
local wezterm = require 'wezterm'

wezterm.on("gui-startup", function(cmd)
  local screen = wezterm.gui.screens().active
  local ratio_x = 0.7
  local ratio_y = 0.8
  local width, height = screen.width * ratio_x, screen.height * ratio_y
  local tab, pane, window = wezterm.mux.spawn_window {
  	position = {
      x = (screen.width - width)/2,
      y = (screen.height - height)/2,
      origin = 'ActiveScreen'
    }
  }
  window:gui_window():set_inner_size(width, height)
end)

return {
  -- General options
  check_for_updates = false,
  adjust_window_size_when_changing_font_size = false,

  -- Font configuration
  font = wezterm.font('MesloLGS NF', { weight = 'Regular' }),
  font_size = 17.0,

  -- Colors
  colors = {
    foreground = '#ffffff',
    background = '#282935',
    cursor_bg = '#ffffff',
    cursor_fg = '#000000',
    cursor_border = '#ffffff',

    ansi = {
      '#000000', -- black
      '#c91b00', -- red
      '#00c300', -- green
      '#c7c400', -- yellow
      '#0226c8', -- blue
      '#ca30c7', -- magenta
      '#00c5c8', -- cyan
      '#c7c7c7', -- white
    },
    brights = {
      '#686868', -- bright black
      '#ff6e68', -- bright red
      '#60fa67', -- bright green
      '#fffc67', -- bright yellow
      '#6872ff', -- bright blue
      '#ff77ff', -- bright magenta
      '#5ffdff', -- bright cyan
      '#ffffff', -- bright white
    },
  },

  -- Cursor style
  default_cursor_style = 'SteadyBar',
  cursor_blink_rate = 600,

  -- Scrollback
  scrollback_lines = 10000,

  -- Workspace
  default_workspace = "home",

  -- Audible bell
  audible_bell = "Disabled",

  -- Tmux
  default_prog = { os.getenv("HOME") .. "/.local/share/zinit/polaris/bin/tmux", "-l", "new-session", "-A", "-s", "main" },

  -- Mouse configuration
  -- alternate_buffer_wheel_scroll_speed = 1,
  hide_mouse_cursor_when_typing = false,

  -- Key bindings
  disable_default_key_bindings = true,
  keys = {
    { key = 'LeftArrow', mods = 'ALT', action = wezterm.action { SendString = '\x1bb' } }, -- Alt + Left (Move backward one word)
    { key = 'RightArrow', mods = 'ALT', action = wezterm.action { SendString = '\x1bf' } }, -- Alt + Right (Move forward one word)

    { key = 'w', mods = 'CMD', action = wezterm.action { SendString = '\x02x' } }, -- Cmd + w -> Ctrl-b x (new tmux kill-panel)
    { key = 't', mods = 'CMD', action = wezterm.action { SendString = '\x02c' } }, -- Cmd + t -> Ctrl-b c (new tmux window)
    { key = 'n', mods = 'CMD', action = wezterm.action.DisableDefaultAssignment }, -- Disable Cmd + n (new window)

    { key = 'Enter', mods = 'ALT', action = wezterm.action.DisableDefaultAssignment }, -- Disable Alt + Enter (fullscreen toggle)
    
    -- **Override WezTerm's default tab-switching behavior**
    { key = ']', mods = 'ALT', action = wezterm.action { SendString = '\x02p' } },
	  { key = '[', mods = 'ALT ', action = wezterm.action { SendString = '\x02n' } },

    { key = '[', mods = 'SHIFT | SUPER', action = wezterm.action { SendString = '\x02p' } }, -- Cmd + Shift + [ -> Move to previous tmux pane
    { key = ']', mods = 'SHIFT | SUPER', action = wezterm.action { SendString = '\x02n' } }, -- Cmd + Shift + ] -> Move to next tmux pane

    { key = '{', mods = 'SUPER', action = wezterm.action { SendString = '\x02p' } }, -- Cmd + Shift + [ -> Move to previous tmux pane
    { key = '}', mods = 'SUPER', action = wezterm.action { SendString = '\x02n' } }, -- Cmd + Shift + ] -> Move to next tmux pane
  },

  -- Hyperlink hints
  hyperlink_rules = {
    {
      regex = [[\b(mailto:|https://|http://|news:|file:|git://|ssh:|ftp://)[^\s<>"\(\)\[\]\{\}]+]],
      format = '$0',
    },
  },

  -- Window settings
  window_background_opacity = 1,
  window_padding = {
    left = 30,
    right = 30,
    top = 20,
    bottom = 10,
  },
  window_decorations = 'RESIZE',
  window_close_confirmation = 'NeverPrompt',

  -- Hide tabs
  enable_tab_bar = false,
  -- hide_tab_bar_if_only_one_tab = true,

  -- Clipboard settings
  enable_kitty_keyboard = true, -- Enables clipboard integration
}

Expected Behavior

Switch between Tmux tabs when I pressed the key sequence described above.

Logs

No response

Anything else?

Thank you for the amazing terminal emulator! 🚀

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions