mirror of
https://github.com/TECHNOFAB11/tmux-copyrat.git
synced 2025-12-12 16:10:07 +01:00
chore(docs): add doc to feat: copyrat.tmux
This commit is contained in:
parent
75054d1200
commit
0622ab7bf6
2 changed files with 47 additions and 21 deletions
66
copyrat.tmux
66
copyrat.tmux
|
|
@ -1,7 +1,28 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# This script is run only once at tmux launch.
|
# This scripts provides a default configuration for tmux-copyrat options and key bindings.
|
||||||
# It provides configuration based on the @copyrat-* options set in your `tmux.conf`.
|
# It is run only once at tmux launch.
|
||||||
|
#
|
||||||
|
# Each option and binding can be overridden in your `tmux.conf` by defining options like
|
||||||
|
#
|
||||||
|
# set -g @copyrat-keytable "foobar"
|
||||||
|
# set -g @copyrat-keyswitch "z"
|
||||||
|
# set -g @copyrat-match-bg "magenta"
|
||||||
|
#
|
||||||
|
# and bindings like
|
||||||
|
#
|
||||||
|
# bind-key -T foobar h new-window -d -n "[copyrat]" '/path/to/tmux-copyrat --window-name "[copyrat]" --pattern-name urls'
|
||||||
|
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
#
|
||||||
|
# changing this will probably break integration -
|
||||||
|
#
|
||||||
|
# Just make sure you first open a named window in the background and provide that name to tmux-copyrat.
|
||||||
|
#
|
||||||
|
# Don't even try to run tmux-copyrat with run-shell, this cannot work because Tmux launches these processes
|
||||||
|
# without attaching them to a pty.
|
||||||
|
|
||||||
|
# You could also entirely ignore this file (not even source it) and define all options and bindings
|
||||||
|
# in your `tmux.conf`.
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
BINARY="${CURRENT_DIR}/tmux-copyrat"
|
BINARY="${CURRENT_DIR}/tmux-copyrat"
|
||||||
|
|
@ -18,22 +39,13 @@ setup_option() {
|
||||||
# Sets the window name when copyrat is run, providing a default if @copyrat-window-name was not defined.
|
# Sets the window name when copyrat is run, providing a default if @copyrat-window-name was not defined.
|
||||||
setup_option "window-name" "[copyrat]"
|
setup_option "window-name" "[copyrat]"
|
||||||
|
|
||||||
# DEFAULT_COPYRAT_WINDOW_NAME="[copyrat]"
|
|
||||||
# COPYRAT_WINDOW_NAME=$(tmux show-option -gqv @copyrat-window-name)
|
|
||||||
# COPYRAT_WINDOW_NAME=${COPYRAT_WINDOW_NAME:-$DEFAULT_COPYRAT_WINDOW_NAME}
|
|
||||||
# # overrides with the same value, I did not bother writing a test
|
|
||||||
# tmux set-option -g @copyrat-window-name ${COPYRAT_WINDOW_NAME}
|
|
||||||
|
|
||||||
# Sets the keytable for all bindings, providing a default if @copyrat-keytable was not defined.
|
# Sets the keytable for all bindings, providing a default if @copyrat-keytable was not defined.
|
||||||
# Keytables open a new shortcut space: if 't' is the switcher (see below), prefix + t + <your-shortcut>
|
# Keytables open a new shortcut space: if 't' is the switcher (see below), prefix + t + <your-shortcut>
|
||||||
setup_option "keytable" "cpyrt"
|
setup_option "keytable" "cpyrt"
|
||||||
# DEFAULT_COPYRAT_KEYTABLE="cpyrt"
|
|
||||||
# COPYRAT_KEYTABLE=$(tmux show-option -gqv @copyrat-keytable)
|
|
||||||
# COPYRAT_KEYTABLE=${COPYRAT_KEYTABLE:-$DEFAULT_COPYRAT_KEYTABLE}
|
|
||||||
|
|
||||||
# Sets the key to access the keytable: prefix + <key> + <your-shortcut>
|
# Sets the key to access the keytable: prefix + <key> + <your-shortcut>
|
||||||
# providing a default if @copyrat-keyswitch is not defined.
|
# providing a default if @copyrat-keyswitch is not defined.
|
||||||
setup_option "keyswitch" "u"
|
setup_option "keyswitch" "t"
|
||||||
|
|
||||||
local keyswitch=$(tmux show-option @copyrat-keyswitch)
|
local keyswitch=$(tmux show-option @copyrat-keyswitch)
|
||||||
local keytable=$(tmux show-option @copyrat-keytable)
|
local keytable=$(tmux show-option @copyrat-keytable)
|
||||||
|
|
@ -46,22 +58,36 @@ setup_binding() {
|
||||||
tmux bind-key -T ${keytable} $key new-window -d -n ${window_name} "${BINARY} --window-name ${window_name} --reverse --unique"
|
tmux bind-key -T ${keytable} $key new-window -d -n ${window_name} "${BINARY} --window-name ${window_name} --reverse --unique"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Search
|
# prefix + t + Space searches for all known regexes (noisy and slower)
|
||||||
setup_pattern_binding "space" ""
|
setup_pattern_binding "space" ""
|
||||||
|
# prefix + t + p searches for absolute & relative paths
|
||||||
setup_pattern_binding "p" "--pattern-name path"
|
setup_pattern_binding "p" "--pattern-name path"
|
||||||
|
# prefix + t + u searches for URLs
|
||||||
setup_pattern_binding "u" "--pattern-name url"
|
setup_pattern_binding "u" "--pattern-name url"
|
||||||
|
# prefix + t + m searches for Markdown URLs [...](matched.url)
|
||||||
|
setup_pattern_binding "m" "--pattern-name markdown-url"
|
||||||
|
# prefix + t + h searches for SHA1/2 (hashes)
|
||||||
setup_pattern_binding "h" "--pattern-name sha"
|
setup_pattern_binding "h" "--pattern-name sha"
|
||||||
setup_pattern_binding "d" "--pattern-name docker"
|
# prefix + t + e searches for email addresses (see https://www.regular-expressions.info/email.html)
|
||||||
|
setup_pattern_binding "e" "--pattern-name email"
|
||||||
|
# prefix + t + D searches for docker shas
|
||||||
|
setup_pattern_binding "D" "--pattern-name docker"
|
||||||
|
# prefix + t + c searches for hex colors #aa00f5
|
||||||
setup_pattern_binding "c" "--pattern-name hexcolor"
|
setup_pattern_binding "c" "--pattern-name hexcolor"
|
||||||
setup_pattern_binding "i" "--pattern-name ip"
|
# prefix + t + U searches for UUIDs
|
||||||
|
setup_pattern_binding "U" "--pattern-name uuid"
|
||||||
# DEFAULT_COPYRAT_KEY="space"
|
# prefix + t + d searches for any string of 4+ digits
|
||||||
# COPYRAT_KEY=$(tmux show-option -gqv @copyrat-key)
|
setup_pattern_binding "d" "--pattern-name digits"
|
||||||
# COPYRAT_KEY=${COPYRAT_KEY:-$DEFAULT_COPYRAT_KEY}
|
# prefix + t + m searches for hex numbers: 0xbedead
|
||||||
|
setup_pattern_binding "m" "--pattern-name mem-address"
|
||||||
|
# prefix + t + 4 searches for IPV4
|
||||||
|
setup_pattern_binding "4" "--pattern-name ipv4"
|
||||||
|
# prefix + t + 6 searches for IPV6
|
||||||
|
setup_pattern_binding "6" "--pattern-name ipv6"
|
||||||
|
|
||||||
# tmux bind-key -T ${keytable} "/" command-prompt "search:" new-window -d -n ${COPYRAT_WINDOW_NAME} "${BINARY} --window-name ${COPYRAT_WINDOW_NAME} --reverse --unique --custom-regex '%%'"
|
# tmux bind-key -T ${keytable} "/" command-prompt "search:" new-window -d -n ${COPYRAT_WINDOW_NAME} "${BINARY} --window-name ${COPYRAT_WINDOW_NAME} --reverse --unique --custom-regex '%%'"
|
||||||
|
|
||||||
|
# Auto-install is currently disabled as it requires the user to have cargo installed.
|
||||||
# if [ ! -f "$BINARY" ]; then
|
# if [ ! -f "$BINARY" ]; then
|
||||||
# cd "${CURRENT_DIR}" && cargo build --release
|
# cd "${CURRENT_DIR}" && cargo build --release
|
||||||
# fi
|
# fi
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ pub const PATTERNS: [(&'static str, &'static str); 15] = [
|
||||||
("ipv4", r"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"),
|
("ipv4", r"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"),
|
||||||
("ipv6", r"[A-f0-9:]+:+[A-f0-9:]+[%\w\d]+"),
|
("ipv6", r"[A-f0-9:]+:+[A-f0-9:]+[%\w\d]+"),
|
||||||
("mem-address", r"0x[0-9a-fA-F]+"),
|
("mem-address", r"0x[0-9a-fA-F]+"),
|
||||||
("number", r"[0-9]{4,}"),
|
("digits", r"[0-9]{4,}"),
|
||||||
];
|
];
|
||||||
|
|
||||||
/// Type-safe string Pattern Name (newtype).
|
/// Type-safe string Pattern Name (newtype).
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue