Skip to content

Commit bbce97d

Browse files
authored
Merge branch 'tmux-plugins:master' into add_key_note
2 parents a360a3a + cff343c commit bbce97d

File tree

5 files changed

+28
-5
lines changed

5 files changed

+28
-5
lines changed

docs/restoring_previously_saved_environment.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Restoring previously saved environment
22

33
None of the previous saves are deleted (unless you explicitly do that). All save
4-
files are kept in `~/.tmux/resurrect/` directory.<br/>
4+
files are kept in `~/.tmux/resurrect/` directory, or `~/.local/share/tmux/resurrect`
5+
(unless `${XDG_DATA_HOME}` says otherwise).<br/>
56
Here are the steps to restore to a previous point in time:
67

78
- make sure you start this with a "fresh" tmux instance

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:

save_command_strategies/ps.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ exit_safely_if_empty_ppid() {
1111
}
1212

1313
full_command() {
14-
ps -ao "ppid command" |
14+
ps -ao "ppid,args" |
1515
sed "s/^ *//" |
1616
grep "^${PANE_PID}" |
1717
cut -d' ' -f2-

scripts/helpers.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
default_resurrect_dir="$HOME/.tmux/resurrect"
1+
if [ -d "$HOME/.tmux/resurrect" ]; then
2+
default_resurrect_dir="$HOME/.tmux/resurrect"
3+
else
4+
default_resurrect_dir="${XDG_DATA_HOME:-$HOME/.local/share}"/tmux/resurrect
5+
fi
26
resurrect_dir_option="@resurrect-dir"
37

48
SUPPORTED_VERSION="1.9"

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)