2020-10-10 18:40:14 +03:00
|
|
|
# SendString
|
|
|
|
|
|
|
|
Sends the string specified argument to the terminal in the current tab, as
|
|
|
|
though that text were literally typed into the terminal.
|
|
|
|
|
|
|
|
```lua
|
2022-06-25 16:58:10 +03:00
|
|
|
local wezterm = require 'wezterm'
|
2020-10-10 18:40:14 +03:00
|
|
|
|
|
|
|
return {
|
|
|
|
keys = {
|
2022-07-19 17:54:31 +03:00
|
|
|
{ key = 'm', mods = 'CMD', action = wezterm.action.SendString 'Hello' },
|
|
|
|
},
|
2020-10-10 18:40:14 +03:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
You can also emit escape sequences using `SendString`. This example shows
|
|
|
|
how to bind Alt-LeftArrow/RightArrow to the Alt-b/f, an emacs style
|
|
|
|
keybinding for moving backwards/forwards through a word in a line editor.
|
|
|
|
|
|
|
|
`\x1b` is the ESC character:
|
|
|
|
|
|
|
|
```lua
|
2022-06-25 16:58:10 +03:00
|
|
|
local wezterm = require 'wezterm'
|
|
|
|
local act = wezterm.action
|
2020-10-10 18:40:14 +03:00
|
|
|
|
|
|
|
return {
|
|
|
|
keys = {
|
|
|
|
-- Make Option-Left equivalent to Alt-b which many line editors interpret as backward-word
|
2022-07-19 17:54:31 +03:00
|
|
|
{ key = 'LeftArrow', mods = 'OPT', action = act.SendString '\x1bb' },
|
2020-10-10 18:40:14 +03:00
|
|
|
-- Make Option-Right equivalent to Alt-f; forward-word
|
2022-07-19 17:54:31 +03:00
|
|
|
{ key = 'RightArrow', mods = 'OPT', action = act.SendString '\x1bf' },
|
|
|
|
},
|
2020-10-10 18:40:14 +03:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-09-04 23:01:34 +03:00
|
|
|
See also [SendKey](SendKey.md) which makes the example above much more convenient,
|
|
|
|
and [Multiple](Multiple.md) for combining multiple actions in a single press.
|