mirror of
https://github.com/tmux-plugins/tmux-resurrect.git
synced 2024-12-25 00:28:49 +00:00
Restore command args for inline strategies with '*'
Example inline strategy: "~/bin/my_program->my_program *" for full command: "ruby /Users/john/bin/my_program arg1 arg2" restores command: "my_program arg1 arg2"
This commit is contained in:
parent
bd671b83dc
commit
e4e21f3f48
@ -28,6 +28,7 @@
|
||||
- `view` added to the list of automatically restored programs
|
||||
- Enable vim session strategy to work with custom session files,
|
||||
e.g. `vim -S Session1.vim`.
|
||||
- Enable restoring command arguments for inline strategies with `*` character.
|
||||
|
||||
### v2.4.0, 2015-02-23
|
||||
- add "tmux-test"
|
||||
|
@ -112,6 +112,32 @@ _get_proc_restore_element() {
|
||||
echo "$1" | sed "s/.*${inline_strategy_token}//"
|
||||
}
|
||||
|
||||
# given full command: 'ruby /Users/john/bin/my_program arg1 arg2'
|
||||
# and inline strategy: '~bin/my_program->my_program *'
|
||||
# returns: 'arg1 arg2'
|
||||
_get_command_arguments() {
|
||||
local pane_full_command="$1"
|
||||
local match="$2"
|
||||
if _proc_starts_with_tildae "$match"; then
|
||||
match="$(remove_first_char "$match")"
|
||||
fi
|
||||
echo "$pane_full_command" | sed "s,^.*${match}[^ ]* ,,"
|
||||
}
|
||||
|
||||
_get_proc_restore_command() {
|
||||
local pane_full_command="$1"
|
||||
local proc="$2"
|
||||
local match="$3"
|
||||
local restore_element="$(_get_proc_restore_element "$proc")"
|
||||
if [[ "$restore_element" =~ " ${inline_strategy_arguments_token}" ]]; then
|
||||
# replaces "%" with command arguments
|
||||
local command_arguments="$(_get_command_arguments "$pane_full_command" "$match")"
|
||||
echo "$restore_element" | sed "s/${inline_strategy_arguments_token}/${command_arguments}/"
|
||||
else
|
||||
echo "$restore_element"
|
||||
fi
|
||||
}
|
||||
|
||||
_restore_list() {
|
||||
local user_processes="$(get_tmux_option "$restore_processes_option" "$restore_processes")"
|
||||
local default_processes="$(get_tmux_option "$default_proc_list_option" "$default_proc_list")"
|
||||
@ -137,7 +163,7 @@ _get_inline_strategy() {
|
||||
if [[ "$proc" =~ "$inline_strategy_token" ]]; then
|
||||
match="$(_get_proc_match_element "$proc")"
|
||||
if _proc_matches_full_command "$pane_full_command" "$match"; then
|
||||
echo "$(_get_proc_restore_element "$proc")"
|
||||
echo "$(_get_proc_restore_command "$pane_full_command" "$proc" "$match")"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
@ -25,6 +25,7 @@ restore_processes=""
|
||||
restore_process_strategy_option="@resurrect-strategy-"
|
||||
|
||||
inline_strategy_token="->"
|
||||
inline_strategy_arguments_token="*"
|
||||
|
||||
save_command_strategy_option="@resurrect-save-command-strategy"
|
||||
default_save_command_strategy="ps"
|
||||
|
Loading…
Reference in New Issue
Block a user