Skip to content

Commit 6df0405

Browse files
authored
Merge pull request #469 from ktprograms/restore-arguments-misc-fixes
Restore with command arguments misc fixes
2 parents a2ddfb9 + 299c4aa commit 6df0405

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

docs/restoring_programs.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ contains space-separated list of additional programs to restore.
2828

2929
set -g @resurrect-processes 'some_program "grunt->grunt development"'
3030

31+
- Use `*` to expand the arguments from the saved command when restoring:
32+
33+
set -g @resurrect-processes 'some_program "~rails server->rails server *"'
34+
3135
- Don't restore any programs:
3236

3337
set -g @resurrect-processes 'false'
@@ -96,6 +100,20 @@ command name".
96100
Full (long) process name is now ignored and you'll see just `rails server` in
97101
the command line when the program is restored.
98102

103+
> What is asterisk `*` and why is it used?
104+
105+
(Please read the above clarifications about tilde `~` and arrow `->`).
106+
107+
Continuing with the `rails server` example, you might have added flags for e.g.
108+
verbose logging, but with the above configuration, the flags would be lost.
109+
110+
To preserve the command arguments when restoring, use the asterisk `*`: (**note**: there **must** be a space before `*`)
111+
112+
set -g @resurrect-processes '"~rails server->rails server *"'
113+
114+
This option says: "when this process is restored use `rails server` as the
115+
command name, but preserve its arguments".
116+
99117
> Now I understand the tilde and the arrow, but things still don't work for me
100118
101119
Here's the general workflow for figuring this out:

scripts/process_restore_helpers.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ _get_command_arguments() {
121121
if _proc_starts_with_tildae "$match"; then
122122
match="$(remove_first_char "$match")"
123123
fi
124-
echo "$pane_full_command" | sed "s,^.*${match}[^ ]* ,,"
124+
echo "$pane_full_command" | sed "s,^.*${match}[^ ]* *,,"
125125
}
126126

127127
_get_proc_restore_command() {
@@ -132,7 +132,7 @@ _get_proc_restore_command() {
132132
if [[ "$restore_element" =~ " ${inline_strategy_arguments_token}" ]]; then
133133
# replaces "%" with command arguments
134134
local command_arguments="$(_get_command_arguments "$pane_full_command" "$match")"
135-
echo "$restore_element" | sed "s/${inline_strategy_arguments_token}/${command_arguments}/"
135+
echo "$restore_element" | sed "s,${inline_strategy_arguments_token},${command_arguments},"
136136
else
137137
echo "$restore_element"
138138
fi

0 commit comments

Comments
 (0)