### Install and Apply Quick Select Plugin Source: https://github.com/quantonganh/quickselect.wezterm/blob/main/README.md Demonstrates how to load the plugin from its repository and apply its default configuration to the WezTerm config object. ```lua local quickselect_plugin = wezterm.plugin.require 'https://github.com/quantonganh/quickselect.wezterm' quickselect_plugin.apply_to_config(config) ``` -------------------------------- ### Initialize Quick Select Plugin in WezTerm Config Source: https://context7.com/quantonganh/quickselect.wezterm/llms.txt The `apply_to_config` function is the main entry point for initializing the Quick Select plugin. It configures WezTerm with key bindings and pattern matching. Customizations include keyboard shortcuts, supported file extensions, regex patterns, and custom actions. This function takes the WezTerm config object and an optional table of options as arguments. ```lua -- ~/.wezterm.lua local wezterm = require("wezterm") local config = wezterm.config_builder() -- Load the Quick Select plugin local quickselect_plugin = wezterm.plugin.require 'https://github.com/quantonganh/quickselect.wezterm' -- Basic usage with default settings (CMD+SHIFT+s to activate) quickselect_plugin.apply_to_config(config) -- Or with custom options quickselect_plugin.apply_to_config(config, { -- Custom key binding key = "q", mods = "CTRL|SHIFT", -- Custom file extensions to open in editor text_extensions = { md = true, c = true, go = true, rs = true, java = true, py = true, -- Add Python support ts = true, -- Add TypeScript support tsx = true, -- Add TSX support }, -- Custom patterns to match in terminal output patterns = { 'https?://\S+', -- URLs '[^\s]+\.rs:\d+:\d+', -- Rust: file.rs:10:5 '[^\s]+\.go:\d+:\d+', -- Go: file.go:10:5 '[^\s]+\.py:\d+', -- Python: file.py:10 'File "([^"]+)", line (\d+)' -- Python tracebacks }, -- Pane split direction: "Up", "Down", "Left", or "Right" direction = "Right", }) return config ``` -------------------------------- ### Define prefix-based actions with filters.startswith Source: https://context7.com/quantonganh/quickselect.wezterm/llms.txt Uses the startswith filter to trigger specific actions when a selection begins with a defined prefix. This is ideal for handling URLs, command patterns, or custom documentation tags. ```lua local quickselect_plugin = wezterm.plugin.require 'https://github.com/quantonganh/quickselect.wezterm' quickselect_plugin.apply_to_config(config, { actions = { -- Open URLs starting with "http" in the default browser { filter = quickselect_plugin.filters.startswith("http"), action = function(_, _, selection, _) wezterm.open_with(selection) end, }, -- Handle rustc --explain commands { filter = quickselect_plugin.filters.startswith("rustc --explain"), action = function(window, pane, selection, _) local code = selection:match("(%S+)$") window:perform_action( wezterm.action.SplitPane({ direction = "Right", command = { args = { "/bin/sh", "-c", "rustc --explain " .. code .. " | mdcat -p" }, }, }), pane ) end, }, -- Custom prefix for opening documentation { filter = quickselect_plugin.filters.startswith("docs:"), action = function(_, _, selection, _) local topic = selection:gsub("^docs:", "") wezterm.open_with("https://docs.rs/" .. topic) end, }, }, }) ``` -------------------------------- ### Configure Key Bindings for WezTerm Source: https://github.com/quantonganh/quickselect.wezterm/blob/main/README.md Shows the recommended method for merging custom key bindings with the plugin's configuration to prevent overwriting existing keymaps. ```lua local my_keys = { ... } for _, keymap in ipairs(my_keys) do table.insert(config.keys, keymap) end ``` -------------------------------- ### Configure Quick Select Plugin in WezTerm Source: https://context7.com/quantonganh/quickselect.wezterm/llms.txt This Lua code snippet demonstrates how to load and apply the Quick Select WezTerm plugin. It includes comprehensive configuration options such as keyboard shortcuts, editor split direction, supported file extensions for Helix, and various patterns for recognizing different types of output in the terminal. It also shows how to define custom actions with filters for specific output patterns. ```lua -- ~/.wezterm.lua local wezterm = require("wezterm") local act = wezterm.action local config = wezterm.config_builder() -- Load Quick Select plugin local quickselect = wezterm.plugin.require 'https://github.com/quantonganh/quickselect.wezterm' -- Apply with comprehensive configuration quickselect.apply_to_config(config, { -- Keyboard shortcut to activate quick select key = "s", mods = "CMD|SHIFT", -- Direction for editor split pane direction = "Up", -- Supported file extensions for opening in Helix text_extensions = { -- Systems programming rs = true, c = true, cpp = true, h = true, -- Go go = true, -- JVM java = true, kt = true, scala = true, -- Web development js = true, ts = true, tsx = true, jsx = true, -- Scripting py = true, rb = true, lua = true, -- Documentation md = true, txt = true, -- Lisp family scm = true, rkt = true, clj = true, }, -- Patterns to recognize in terminal output patterns = { -- URLs 'https?://\S+', -- Generic file:line:column format '^/[^/\r\n]+(?:/[^/\r\n]+)*:\d+:\d+', -- Rust errors '[^\s]+\.rs:\d+:\d+', 'rustc --explain E\d+', -- Go errors '[^\s]+\.go:\d+', '[^\s]+\.go:\d+:\d+', -- Java errors '[^\s]+\.java:\[\d+,\d+\]', -- Python tracebacks 'File "[^"]+", line \d+', -- TypeScript/Node errors '[^\s]+\.ts:\d+:\d+', -- JSON objects (for pretty printing) '[^{]*{.*}', }, -- Custom action handlers actions = { { filter = quickselect.filters.startswith("http"), action = function(_, _, selection, _) wezterm.open_with(selection) end, }, { filter = quickselect.filters.startswith("rustc --explain"), action = function(window, pane, selection, _) local code = selection:match("(%S+)$") window:perform_action( act.SplitPane({ direction = "Right", command = { args = { "/bin/sh", "-c", "rustc --explain " .. code .. " | mdcat -p" } }, }), pane ) end, }, { filter = quickselect.filters.match("[^{]*{.*}"), action = function(window, pane, selection, _) local json = selection:match("{.*}") window:perform_action( act.SplitPane({ direction = "Right", command = { args = { "/bin/sh", "-c", "echo '" .. json .. "' | jq -C . | less -R" } }, }), pane ) end, }, }, }) -- Important: Preserve plugin key bindings when adding custom keys local my_keys = { { key = "c", mods = "CMD", action = act.CopyTo("Clipboard") }, { key = "v", mods = "CMD", action = act.PasteFrom("Clipboard") }, } for _, keymap in ipairs(my_keys) do table.insert(config.keys, keymap) end return config ``` -------------------------------- ### Open File in Helix Editor with WezTerm Split Pane Source: https://context7.com/quantonganh/quickselect.wezterm/llms.txt The `open_with_hx` function opens a specified file in the Helix editor within a WezTerm split pane. It intelligently reuses existing Helix instances or creates new ones. The function expects file paths prefixed with `$EDITOR:` and validates file extensions against a whitelist. This is typically used internally but can be called for custom actions. ```lua -- This function is called internally by the plugin when a file pattern is matched -- Manual usage example for custom actions: local quickselect_plugin = wezterm.plugin.require 'https://github.com/quantonganh/quickselect.wezterm' quickselect_plugin.apply_to_config(config, { actions = { { -- Custom action for TypeScript files with specific format filter = quickselect_plugin.filters.match("[^\s]+\.ts:\d+:\d+"), action = function(window, pane, selection, opts) -- Prepend $EDITOR: protocol for the open_with_hx function local formatted = "$EDITOR:" .. selection return quickselect_plugin.open_with_hx(window, pane, formatted, opts) end, }, }, }) -- The function expects URLs in the format: $EDITOR:filename.ext:line:column -- Example matches that will open in Helix: -- $EDITOR:main.rs:42:10 -> Opens main.rs at line 42, column 10 -- $EDITOR:src/lib.go:100:5 -> Opens src/lib.go at line 100, column 5 -- $EDITOR:App.java:25:1 -> Opens App.java at line 25, column 1 ``` -------------------------------- ### Define Supported Extensions and Regex Patterns Source: https://github.com/quantonganh/quickselect.wezterm/blob/main/README.md Configures the file extensions and regex patterns used by the plugin to identify clickable links or build errors in the terminal output. ```lua local text_extensions = opts.text_extensions or { md = true, c = true, go = true, scm = true, rkt = true, rs = true, java = true, } local patterns = opts.patterns or { 'https?://\\S+', '^/[^/\r\n]+(?:/[^/\r\n]+)*:\\d+:\\d+', '[^\\s]+\\.rs:\\d+:\\d+', 'rustc --explain E\\d+', '[^\\s]+\\.go:\\d+', '[^\\s]+\\.go:\\d+:\\d+', '[^\\s]+\\.java:\[\\d+,\\d+\]', '[^{]*{.*}', } ``` -------------------------------- ### Define pattern-based actions with filters.match Source: https://context7.com/quantonganh/quickselect.wezterm/llms.txt Uses the match filter to apply actions based on Lua pattern matching. This allows for sophisticated parsing of structured text like file paths, line numbers, and error logs. ```lua local quickselect_plugin = wezterm.plugin.require 'https://github.com/quantonganh/quickselect.wezterm' quickselect_plugin.apply_to_config(config, { actions = { -- Match and format JSON objects for pretty printing { filter = quickselect_plugin.filters.match("[^{]*{.*}"), action = function(window, pane, selection, _) local json = selection:match("{.*}") local cmd = "echo '" .. json .. "' | jq -C . | less -R" window:perform_action( wezterm.action.SplitPane({ direction = "Right", command = { args = { "/bin/sh", "-c", cmd } }, }), pane ) end, }, -- Match Java compiler error format: File.java:[line,column] { filter = quickselect_plugin.filters.match("[^:%s]+%.java):%[(%d+),%d+%]"), action = function(window, pane, selection, opts) local file, line = selection:match("([^:%s]+%.java):%[(%d+),%d+%]") if file and line then selection = "$EDITOR:" .. file .. ":" .. line end return quickselect_plugin.open_with_hx(window, pane, selection, opts) end, }, -- Match Python traceback format { filter = quickselect_plugin.filters.match('File "[^"]+", line %d+'), action = function(window, pane, selection, opts) local file, line = selection:match('File "([^"]+)", line (%d+)') if file and line then selection = "$EDITOR:" .. file .. ":" .. line .. ":1" return quickselect_plugin.open_with_hx(window, pane, selection, opts) end end, }, }, }) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.