diff options
| author | srdusr <trevorgray@srdusr.com> | 2023-06-09 23:15:48 +0200 |
|---|---|---|
| committer | srdusr <trevorgray@srdusr.com> | 2023-06-09 23:15:48 +0200 |
| commit | 93d8aecd32fa3b8954aa707678166567eb2970a9 (patch) | |
| tree | 5ea96145522adeceada977ae3ebb2bbe9d605ce3 /.config/wezterm | |
| parent | 3376c72eb9f31ef7230a1dad6c67449321d1ae78 (diff) | |
| download | dotfiles-93d8aecd32fa3b8954aa707678166567eb2970a9.tar.gz dotfiles-93d8aecd32fa3b8954aa707678166567eb2970a9.zip | |
Changed key C-c to be conditional
Diffstat (limited to '.config/wezterm')
| -rw-r--r-- | .config/wezterm/wezterm.lua | 79 |
1 files changed, 74 insertions, 5 deletions
diff --git a/.config/wezterm/wezterm.lua b/.config/wezterm/wezterm.lua index 544b04f..de48ad6 100644 --- a/.config/wezterm/wezterm.lua +++ b/.config/wezterm/wezterm.lua @@ -1,5 +1,57 @@ local wezterm = require 'wezterm' +---- Function to unset Ctrl+C keybinding +--local function unsetCtrlCKeybinding(window) +-- local keys = window:get_config().keys +-- for i, key in ipairs(keys) do +-- if key.key == 'c' and key.mods == 'CTRL' then +-- table.remove(keys, i) +-- break +-- end +-- end +-- window:set_config({ keys = keys }) +--end +-- +---- Event handler to unset Ctrl+C keybinding when using nvim +--wezterm.on("spawn_command", function(window, pane) +-- local cmd = pane:get_command() +-- if cmd and cmd[1] == "nvim" then +-- unsetCtrlCKeybinding(window) +-- end +--end) + +--local function isNvimRunning(window) +-- local pane = window.active_pane +-- local cmd = pane:get_command() +-- return cmd and cmd[1] == "nvim" +--end +-- +---- Function to modify keybindings based on the current program +--local function updateKeybindings(window) +-- local isNvim = isNvimRunning(window) +-- +-- local keys = {} +-- if not isNvim then +-- -- Add the default Ctrl+C keybinding +-- keys = { +-- { +-- key = "c", +-- mods = "CTRL", +-- action = wezterm.action{CopyTo = "ClipboardAndPrimarySelection"} +-- } +-- } +-- end +-- +-- window:set_config({ +-- keys = keys +-- }) +--end +-- +---- Event handler to update keybindings when the active program changes +--wezterm.on("update-right-status", function(window) +-- updateKeybindings(window) +--end) + wezterm.on("toggle-opacity", function(window) local overrides = window:get_config_overrides() or {} if not overrides.window_background_opacity then @@ -72,11 +124,28 @@ return { mods = "CTRL", action = wezterm.action({ PasteFrom = "Clipboard" }), }, - { - key = "c", - mods = "CTRL", - action = wezterm.action({ CopyTo = "ClipboardAndPrimarySelection" }), - }, + --{ + -- key = "c", + -- mods = "CTRL", + -- action = wezterm.action({ CopyTo = "ClipboardAndPrimarySelection" }), + --}, + { + key="c", + mods="CTRL", + action = wezterm.action_callback(function(window, pane) + local has_selection = window:get_selection_text_for_pane(pane) ~= "" + if has_selection then + window:perform_action( + wezterm.action{CopyTo="ClipboardAndPrimarySelection"}, + pane) + window:perform_action("ClearSelection", pane) + else + window:perform_action( + wezterm.action{SendKey={key="c", mods="CTRL"}}, + pane) + end + end) + } }, -- Aesthetic Night Colorscheme --bold_brightens_ansi_colors = true, |
