1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-27 07:18:13 +03:00
wezterm/docs/config/lua/keyassignment/ClearSelection.md

40 lines
934 B
Markdown
Raw Normal View History

# ClearSelection
2022-06-25 00:58:18 +03:00
*Since: 20220624-141144-bd1b7c5d*
Clears the selection in the current pane.
This example shows how to rebind `CTRL-C` to copy to the clipboard
when there is a selection present (clearing it afterwards) or sending
CTRL-C to the terminal when there is no selection:
```lua
local wezterm = require 'wezterm'
local act = wezterm.action
return {
keys = {
{
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(
act.CopyTo 'ClipboardAndPrimarySelection',
2022-07-19 16:58:38 +03:00
pane
)
window:perform_action(act.ClearSelection, pane)
else
window:perform_action(
act.SendKey { key = 'c', mods = 'CTRL' },
2022-07-19 16:58:38 +03:00
pane
)
end
end),
},
},
}
```