### Configure WezTerm Replay Plugin Source: https://github.com/btrachey/wezterm-replay/blob/main/README.md Standard setup for integrating the WezTerm Replay plugin into the user's configuration file. It requires the plugin module and applies it to the WezTerm configuration object. ```lua local wezterm_replay = wezterm.plugin.require("https://github.com/btrachey/wezterm-replay") wezterm_replay.apply_to_config(config) ``` -------------------------------- ### Implement Built-in Extractor Logic Source: https://context7.com/btrachey/wezterm-replay/llms.txt Examples of the internal logic used for built-in extractors like backtick command extraction and URI parsing. These functions demonstrate how to process text buffers for specific patterns. ```lua -- Backticks extractor { label = 'backticks', extractor = function(s) local matches = {} for match in string.gmatch(s, '`(.*)`') do table.insert(matches, match) end return matches end, } -- URI extractor { label = 'URIs', prefix = 'open', extractor = function(s) local url_regexes = { '%((%w+://%S+)%)', '%[(%w+://%S+)%]', '%{(%w+://%S+)%}', '%<(%w+://%S+)%>', '%w+://%S+' } local matches = {} for _, regex in ipairs(url_regexes) do for match in string.gmatch(s, regex) do if match and #match > 0 then string.gsub(match, '[\n\r]', '') table.insert(matches, match) end end end return matches end, } ``` -------------------------------- ### Configure WezTerm Replay plugin Source: https://context7.com/btrachey/wezterm-replay/llms.txt Initializes the plugin within the WezTerm configuration. It supports default keybindings or custom options for key triggers and behavior modification. ```lua local wezterm = require('wezterm') local config = wezterm.config_builder() -- Load the plugin local wezterm_replay = wezterm.plugin.require("https://github.com/btrachey/wezterm-replay") -- Basic setup with defaults (LEADER-r for replay, LEADER-q for recall) wezterm_replay.apply_to_config(config) -- Or with custom options local opts = { replay_key = "l", -- Change replay trigger to LEADER-l recall_key = "u", -- Change recall trigger to LEADER-u skip_keybinds = false, -- Set true to disable automatic keybind setup } wezterm_replay.apply_to_config(config, opts) return config ``` -------------------------------- ### Configure Plugin with Custom Options Source: https://github.com/btrachey/wezterm-replay/blob/main/README.md Initialize the plugin with 'skip_keybinds' set to true to prevent automatic default keybinding assignment. This is required when implementing custom triggers for the plugin functions. ```Lua local config = wezterm.config_builder() local wezterm_replay = wezterm.plugin.require("https://github.com/btrachey/wezterm-replay") local opts = { skip_keybinds = true } wezterm_replay.apply_to_config(config, opts) ``` -------------------------------- ### Implement Replay action Source: https://context7.com/btrachey/wezterm-replay/llms.txt Returns a WezTerm action that parses the previous command's output. It triggers an interactive picker if multiple matches are found or executes immediately if a single match exists. ```lua local wezterm = require('wezterm') local wezterm_replay = wezterm.plugin.require("https://github.com/btrachey/wezterm-replay") -- Use directly in custom keybinding config.keys = { { key = "r", mods = "CTRL|SHIFT", action = wezterm_replay.replay(), }, } ``` -------------------------------- ### Customize Plugin Keybindings Source: https://github.com/btrachey/wezterm-replay/blob/main/README.md Demonstrates how to override default trigger keys for the replay and recall functionality by passing an options table to the apply_to_config function. ```lua local config = wezterm.config_builder() local wezterm_replay = wezterm.plugin.require("https://github.com/btrachey/wezterm-replay") local opts = { replay_key = "l", recall_key = "u" } wezterm_replay.apply_to_config(config, opts) ``` -------------------------------- ### Implement Recall action Source: https://context7.com/btrachey/wezterm-replay/llms.txt Returns a WezTerm action to retrieve previously cached extraction results. This allows users to re-select from previous matches without re-parsing the command output. ```lua local wezterm = require('wezterm') local wezterm_replay = wezterm.plugin.require("https://github.com/btrachey/wezterm-replay") -- Use directly in custom keybinding config.keys = { { key = "q", mods = "CTRL|SHIFT", action = wezterm_replay.recall(), }, } ``` -------------------------------- ### Define Custom Extractors with Lua Patterns Source: https://context7.com/btrachey/wezterm-replay/llms.txt Configure custom extractors using Lua pattern strings for simple text matching. These patterns are applied via string.gmatch and cannot be used alongside custom extractor functions. ```lua local wezterm = require('wezterm') local config = wezterm.config_builder() local wezterm_replay = wezterm.plugin.require("https://github.com/btrachey/wezterm-replay") local opts = { extractors = { { label = "ip_addresses", prefix = "ping", postfix = nil, pattern = "(%d+%.%d+%.%d+%.%d+)", }, { label = "email_addresses", prefix = "mail", postfix = nil, pattern = "([%w%.%-_]+@[%w%.%-]+%.%w+)", }, { label = "hex_colors", prefix = nil, postfix = nil, pattern = "(#[%x][%x][%x][%x][%x][%x])", }, }, } wezterm_replay.apply_to_config(config, opts) return config ``` -------------------------------- ### Define Custom Extractors Source: https://github.com/btrachey/wezterm-replay/blob/main/README.md Shows the structure for defining custom data extractors using either Lua patterns or custom functions. These extractors can be passed to the plugin configuration to handle specific parsing logic. ```lua local opts = { extractors = { { label = "numbers_only", prefix = nil, postfix = nil, extractor = function(s) local matches = {} for match in string:gmatch(s, '%d') do table.insert(matches, match) end return matches end } } } wezterm_replay.apply_to_config(config, opts) ``` -------------------------------- ### Define custom extractors Source: https://context7.com/btrachey/wezterm-replay/llms.txt Allows users to define custom logic for parsing command output using Lua functions. Extractors can include labels, prefixes, and postfixes to format the final command string. ```lua local wezterm = require('wezterm') local config = wezterm.config_builder() local wezterm_replay = wezterm.plugin.require("https://github.com/btrachey/wezterm-replay") local opts = { extractors = { { label = "docker_containers", prefix = "docker exec -it", postfix = "/bin/bash", extractor = function(s) local matches = {} for match in string.gmatch(s, "([a-f0-9]+)%s+%w+%s+%w+") do if #match == 12 then table.insert(matches, match) end end return matches end, }, { label = "file_paths", prefix = "code", postfix = nil, extractor = function(s) local matches = {} for match in string.gmatch(s, "(/[%w%._%-/]+%.[%w]+)") do table.insert(matches, match) end return matches end, }, }, } wezterm_replay.apply_to_config(config, opts) return config ``` -------------------------------- ### Configure Custom Keybindings for Replay and Recall Source: https://context7.com/btrachey/wezterm-replay/llms.txt Disable automatic keybindings to manually map replay and recall actions to specific keys. This provides granular control over the plugin's trigger mechanisms. ```lua local wezterm = require('wezterm') local config = wezterm.config_builder() local wezterm_replay = wezterm.plugin.require("https://github.com/btrachey/wezterm-replay") local opts = { skip_keybinds = true, extractors = { { label = "numbers", prefix = nil, postfix = nil, pattern = "(%d+)", }, }, } wezterm_replay.apply_to_config(config, opts) config.keys = { { key = "R", mods = "CTRL|SHIFT", action = wezterm_replay.replay() }, { key = "E", mods = "CTRL|SHIFT", action = wezterm_replay.recall() }, { key = "F9", mods = "NONE", action = wezterm_replay.replay() }, { key = "F10", mods = "NONE", action = wezterm_replay.recall() }, } return config ``` -------------------------------- ### Manually Trigger Replay and Recall Functions Source: https://github.com/btrachey/wezterm-replay/blob/main/README.md Directly invoke the replay and recall functions provided by the plugin. This allows for custom keybinding implementation outside of the plugin's default behavior. ```Lua wezterm_replay.replay() wezterm_replay.recall() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.