Merge branch 'tmux-plugins:master' into add_key_note

pull/454/head
Jason Gomez 2023-05-14 05:09:37 +01:00 committed by GitHub
commit bbce97dbd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 5 deletions

View File

@ -1,7 +1,8 @@
# Restoring previously saved environment # Restoring previously saved environment
None of the previous saves are deleted (unless you explicitly do that). All save None of the previous saves are deleted (unless you explicitly do that). All save
files are kept in `~/.tmux/resurrect/` directory.<br/> files are kept in `~/.tmux/resurrect/` directory, or `~/.local/share/tmux/resurrect`
(unless `${XDG_DATA_HOME}` says otherwise).<br/>
Here are the steps to restore to a previous point in time: Here are the steps to restore to a previous point in time:
- make sure you start this with a "fresh" tmux instance - make sure you start this with a "fresh" tmux instance

View File

@ -28,6 +28,10 @@ contains space-separated list of additional programs to restore.
set -g @resurrect-processes 'some_program "grunt->grunt development"' set -g @resurrect-processes 'some_program "grunt->grunt development"'
- Use `*` to expand the arguments from the saved command when restoring:
set -g @resurrect-processes 'some_program "~rails server->rails server *"'
- Don't restore any programs: - Don't restore any programs:
set -g @resurrect-processes 'false' set -g @resurrect-processes 'false'
@ -96,6 +100,20 @@ command name".
Full (long) process name is now ignored and you'll see just `rails server` in Full (long) process name is now ignored and you'll see just `rails server` in
the command line when the program is restored. the command line when the program is restored.
> What is asterisk `*` and why is it used?
(Please read the above clarifications about tilde `~` and arrow `->`).
Continuing with the `rails server` example, you might have added flags for e.g.
verbose logging, but with the above configuration, the flags would be lost.
To preserve the command arguments when restoring, use the asterisk `*`: (**note**: there **must** be a space before `*`)
set -g @resurrect-processes '"~rails server->rails server *"'
This option says: "when this process is restored use `rails server` as the
command name, but preserve its arguments".
> Now I understand the tilde and the arrow, but things still don't work for me > Now I understand the tilde and the arrow, but things still don't work for me
Here's the general workflow for figuring this out: Here's the general workflow for figuring this out:

View File

@ -11,7 +11,7 @@ exit_safely_if_empty_ppid() {
} }
full_command() { full_command() {
ps -ao "ppid command" | ps -ao "ppid,args" |
sed "s/^ *//" | sed "s/^ *//" |
grep "^${PANE_PID}" | grep "^${PANE_PID}" |
cut -d' ' -f2- cut -d' ' -f2-

View File

@ -1,4 +1,8 @@
default_resurrect_dir="$HOME/.tmux/resurrect" if [ -d "$HOME/.tmux/resurrect" ]; then
default_resurrect_dir="$HOME/.tmux/resurrect"
else
default_resurrect_dir="${XDG_DATA_HOME:-$HOME/.local/share}"/tmux/resurrect
fi
resurrect_dir_option="@resurrect-dir" resurrect_dir_option="@resurrect-dir"
SUPPORTED_VERSION="1.9" SUPPORTED_VERSION="1.9"

View File

@ -121,7 +121,7 @@ _get_command_arguments() {
if _proc_starts_with_tildae "$match"; then if _proc_starts_with_tildae "$match"; then
match="$(remove_first_char "$match")" match="$(remove_first_char "$match")"
fi fi
echo "$pane_full_command" | sed "s,^.*${match}[^ ]* ,," echo "$pane_full_command" | sed "s,^.*${match}[^ ]* *,,"
} }
_get_proc_restore_command() { _get_proc_restore_command() {
@ -132,7 +132,7 @@ _get_proc_restore_command() {
if [[ "$restore_element" =~ " ${inline_strategy_arguments_token}" ]]; then if [[ "$restore_element" =~ " ${inline_strategy_arguments_token}" ]]; then
# replaces "%" with command arguments # replaces "%" with command arguments
local command_arguments="$(_get_command_arguments "$pane_full_command" "$match")" local command_arguments="$(_get_command_arguments "$pane_full_command" "$match")"
echo "$restore_element" | sed "s/${inline_strategy_arguments_token}/${command_arguments}/" echo "$restore_element" | sed "s,${inline_strategy_arguments_token},${command_arguments},"
else else
echo "$restore_element" echo "$restore_element"
fi fi