Skip to content

Instantly share code, notes, and snippets.

@henri
Last active July 2, 2024 03:27
Show Gist options
  • Save henri/cf3f054c37b7acb6b0dda8dc5be7fe04 to your computer and use it in GitHub Desktop.
Save henri/cf3f054c37b7acb6b0dda8dc5be7fe04 to your computer and use it in GitHub Desktop.
wezterm cheat sheet
# pane splitting cli
https://wezfurlong.org/wezterm/cli/cli/split-pane.html
# default pane movement basic (arrow keys)
shift-control-leftarrow
shift-control-rightarrow
shift-control-uparrow
shift-control-downarrow
# get some help with the command line
wezterm cli --help
-- Pull in the wezterm API
local wezterm = require 'wezterm'
-- This will hold the configuration
local config = wezterm.config_builder()
-- This will hold the actions
local act = wezterm.action
-- config.color_scheme = 'AdventureTime'
font = wezterm.font('JetBrainsMono Nerd Font')
-- Spawn a fish shell in login mode
config.default_prog = { '/usr/bin/fish', '-l' }
-- dim inactive pane
config.inactive_pane_hsb = {
saturation = 0.9,
brightness = 0.1,
}
-- Right Mouse Click Copy and Paste
config.mouse_bindings = {
{
event = { Down = { streak = 1, button = "Right" } },
mods = "NONE",
action = wezterm.action_callback(function(window, pane)
local has_selection = window:get_selection_text_for_pane(pane) ~= ""
if has_selection then
window:perform_action(act.CopyTo("ClipboardAndPrimarySelection"), pane)
window:perform_action(act.ClearSelection, pane)
else
window:perform_action(act({ PasteFrom = "Clipboard" }), pane)
end
end),
},
}
-- keyboard configuration to close current pane
config.keys = {
-- close pane with confirmation if active process
{
key = 'w',
mods = 'CMD',
action = wezterm.action.CloseCurrentPane { confirm = true },
},
-- name tab
{
key = 'R',
mods = 'CMD|SHIFT',
action = act.PromptInputLine {
description = 'Enter new name for tab',
action = wezterm.action_callback(function(window, _, line)
-- line will be `nil` if they hit escape without entering anything
-- An empty string if they just hit enter
-- Or the actual line of text they wrote
if line then
window:active_tab():set_title(line)
end
end),
},
},
--open wezterm config file
{
key = ',',
mods = 'CMD',
action = act.SpawnCommandInNewTab {
cwd = os.getenv('WEZTERM_CONFIG_DIR'),
set_environment_variables = {
TERM = 'screen-256color',
},
args = {
'nano',
os.getenv('WEZTERM_CONFIG_FILE'),
},
},
},
}
-- and finally, return the configuration to wezterm
return config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment