Add @resurrect-process-match-strategy option and "basename" strategy
parent
b020b2481e
commit
d27d0dd936
|
@ -89,6 +89,8 @@ _process_on_the_restore_list() {
|
||||||
_proc_matches_full_command() {
|
_proc_matches_full_command() {
|
||||||
local pane_full_command="$1"
|
local pane_full_command="$1"
|
||||||
local match="$2"
|
local match="$2"
|
||||||
|
local match_strategy=$(get_tmux_option "$process_match_strategy_option" "$default_process_match_strategy")
|
||||||
|
|
||||||
if _proc_starts_with_tildae "$match"; then
|
if _proc_starts_with_tildae "$match"; then
|
||||||
match="$(remove_first_char "$match")"
|
match="$(remove_first_char "$match")"
|
||||||
# regex matching the command makes sure `$match` string is somewhere in the command string
|
# regex matching the command makes sure `$match` string is somewhere in the command string
|
||||||
|
@ -96,9 +98,17 @@ _proc_matches_full_command() {
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# regex matching the command makes sure process is a "word"
|
if [[ $match_strategy = "basename" ]]; then
|
||||||
if [[ "$pane_full_command" =~ (^${match} ) ]] || [[ "$pane_full_command" =~ (^${match}$) ]]; then
|
# This is roughly equivalent to performing a basename on the first part of the command (program name)
|
||||||
return 0
|
# then matching against the result. It will break on backslash escaped spaces in paths.
|
||||||
|
if [[ "$pane_full_command" =~ (^([^ ]+/)?${match} ) ]] || [[ "$pane_full_command" =~ (^([^ ]+/)?${match}$) ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
else # default to $match_strategy 'full'
|
||||||
|
# regex matching the command makes sure process is a "word"
|
||||||
|
if [[ "$pane_full_command" =~ (^${match} ) ]] || [[ "$pane_full_command" =~ (^${match}$) ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
return 1
|
return 1
|
||||||
|
|
|
@ -20,6 +20,12 @@ default_proc_list='vi vim nvim emacs man less more tail top htop irssi weechat m
|
||||||
restore_processes_option="@resurrect-processes"
|
restore_processes_option="@resurrect-processes"
|
||||||
restore_processes=""
|
restore_processes=""
|
||||||
|
|
||||||
|
# Strategy for matching process names
|
||||||
|
# 'full' - matches from the beginning of the full command
|
||||||
|
# 'basename' - matches against a basename of the first part of the full command
|
||||||
|
process_match_strategy_option="@resurrect-process-match-strategy"
|
||||||
|
default_process_match_strategy="full"
|
||||||
|
|
||||||
# Defines part of the user variable. Example usage:
|
# Defines part of the user variable. Example usage:
|
||||||
# set -g @resurrect-strategy-vim "session"
|
# set -g @resurrect-strategy-vim "session"
|
||||||
restore_process_strategy_option="@resurrect-strategy-"
|
restore_process_strategy_option="@resurrect-strategy-"
|
||||||
|
|
Loading…
Reference in New Issue