Advertisement
jamesonBradfield

keymaps.lua

Jan 9th, 2024 (edited)
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.08 KB | Software | 0 0
  1. -- I am keymaps.lua and I should live in ~/.config/wezterm/keymaps.lua
  2.  
  3. local wezterm = require 'wezterm'
  4. local act = wezterm.action
  5. -- This is the module table that we will export
  6. local module = {}
  7.  
  8. -- This function is private to this module and is not visible
  9. -- outside.
  10. local function private_helper()
  11.   wezterm.log_error 'hello!'
  12. end
  13.  
  14. -- define a function in the module table.
  15. -- Only functions defined in `module` will be exported to
  16. -- code that imports this module.
  17. -- The suggested convention for making modules that update
  18. -- the config is for them to export an `apply_to_config`
  19. -- function that accepts the config object, like this:
  20. function module.apply_to_config(config)
  21.   private_helper()
  22.   config.disable_default_key_bindings = true
  23.   Prefix = "CTRL"
  24.   scalingPrefix = "CTRL|SHIFT"
  25.   config.keys = {
  26.     -- pane navigation.
  27.     {
  28.       key = "h",
  29.       mods = Prefix,
  30.       -- wezterm will "eat" maps for keys not sending them to the terminal.
  31.       -- the fix is act.SendKey.
  32.       action = act.Multiple {
  33.         act.ActivatePaneDirection('Left'),
  34.         act.SendKey {
  35.           key = 'h',
  36.           mods = Prefix,
  37.         },
  38.       },
  39.     },
  40.     {
  41.       key = "l",
  42.       mods = Prefix,
  43.       -- wezterm will "eat" maps for keys not sending them to the terminal.
  44.       -- the fix is act.SendKey.
  45.       action = act.Multiple {
  46.         act.ActivatePaneDirection('Right'),
  47.         act.SendKey {
  48.           key = 'l',
  49.           mods = Prefix,
  50.         },
  51.       },
  52.     },
  53.     {
  54.       key = "k",
  55.       mods = Prefix,
  56.       -- wezterm will "eat" maps for keys not sending them to the terminal.
  57.       -- the fix is act.SendKey.
  58.       action = act.Multiple {
  59.         act.ActivatePaneDirection('Up'),
  60.         act.SendKey {
  61.           key = 'k',
  62.           mods = Prefix,
  63.         },
  64.       },
  65.     },
  66.     {
  67.       key = "j",
  68.       mods = Prefix,
  69.       -- wezterm will "eat" maps for keys not sending them to the terminal.
  70.       -- the fix is act.SendKey.
  71.       action = act.Multiple {
  72.         act.ActivatePaneDirection('Down'),
  73.         act.SendKey {
  74.           key = 'j',
  75.           mods = Prefix,
  76.         },
  77.       },
  78.     },
  79.     {
  80.       key = 'h',
  81.       mods = scalingPrefix,
  82.       action = act.AdjustPaneSize { 'Left', 5 },
  83.     },
  84.     {
  85.       key = 'j',
  86.       mods = scalingPrefix,
  87.       action = act.AdjustPaneSize { 'Down', 5 },
  88.     },
  89.     {
  90.       key = 'k',
  91.       mods = scalingPrefix,
  92.       action = act.AdjustPaneSize { 'Up', 5 }
  93.     },
  94.     {
  95.       key = 'l',
  96.       mods = scalingPrefix,
  97.       action = act.AdjustPaneSize { 'Right', 5 },
  98.     },
  99.     {
  100.       key = 'f',
  101.       mods = scalingPrefix,
  102.       action = wezterm.action.ToggleFullScreen,
  103.     },
  104.     -- tab navigation
  105.     {
  106.       key = "u",
  107.       mods = Prefix,
  108.       action = act.ActivateTabRelative(-1)
  109.     },
  110.     {
  111.       key = "i",
  112.       mods = Prefix,
  113.       action = act.ActivateTabRelative(1)
  114.     },
  115.     {
  116.       key = "-",
  117.       mods = Prefix,
  118.       action = act { SplitVertical = { domain = "CurrentPaneDomain" } }
  119.     },
  120.     {
  121.       key = "\\",
  122.       mods = Prefix,
  123.       action = act { SplitHorizontal = { domain = "CurrentPaneDomain" } }
  124.     },
  125.     {
  126.       key = "z",
  127.       mods = Prefix,
  128.       action = "TogglePaneZoomState"
  129.     },
  130.     {
  131.       key = "y",
  132.       mods = Prefix,
  133.       action = act { SpawnTab = "CurrentPaneDomain" }
  134.     },
  135.     {
  136.       key = "o",
  137.       mods = Prefix,
  138.       action = act { CloseCurrentTab = { confirm = true } }
  139.     },
  140.     {
  141.       key = "x",
  142.       mods = Prefix,
  143.       action = act { CloseCurrentPane = { confirm = true } }
  144.     },
  145.     {
  146.       key = "v",
  147.       mods = "CTRL|SHIFT",
  148.       action = act.PasteFrom 'Clipboard'
  149.     },
  150.     {
  151.       key = "c",
  152.       mods = "CTRL|SHIFT",
  153.       action = act.CopyTo 'Clipboard'
  154.     },
  155.     -- CTRL-SHIFT-l activates the debug overlay
  156.     {
  157.       key = 'd',
  158.       mods = scalingPrefix,
  159.       action = wezterm.action.ShowDebugOverlay
  160.     },
  161.     {
  162.       key = ' ',
  163.       mods = Prefix,
  164.       action = wezterm.action.QuickSelect
  165.     },
  166.   }
  167. end
  168.  
  169. return module
  170.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement