mirror of
https://github.com/tmux-plugins/tmux-resurrect.git
synced 2025-09-10 21:23:09 +00:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
e770c87e10 | |||
601366be6d | |||
059686ab6c | |||
488f086fa5 | |||
fcf7ca13f0 |
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
### master
|
### master
|
||||||
|
|
||||||
|
### v1.5.0, 2014-11-09
|
||||||
|
- add support for restoring neovim sessions
|
||||||
|
|
||||||
### v1.4.0, 2014-10-25
|
### v1.4.0, 2014-10-25
|
||||||
- plugin now uses strategies when fetching pane full command. Implemented
|
- plugin now uses strategies when fetching pane full command. Implemented
|
||||||
'default' strategy.
|
'default' strategy.
|
||||||
|
27
README.md
27
README.md
@ -12,7 +12,7 @@ projects.
|
|||||||
can be completely restored after a system restart (or when you feel like it).
|
can be completely restored after a system restart (or when you feel like it).
|
||||||
No configuration is required. You should feel like you never quit tmux.
|
No configuration is required. You should feel like you never quit tmux.
|
||||||
|
|
||||||
It even (optionally) [restores vim sessions](#restoring-vim-sessions)!
|
It even (optionally) [restores vim and neovim sessions](#restoring-vim-and-neovim-sessions)!
|
||||||
|
|
||||||
### Screencast
|
### Screencast
|
||||||
|
|
||||||
@ -44,8 +44,8 @@ This plugin goes to great lengths to save and restore all the details from your
|
|||||||
- active pane for each window
|
- active pane for each window
|
||||||
- programs running within a pane! More details in the
|
- programs running within a pane! More details in the
|
||||||
[configuration section](#configuration).
|
[configuration section](#configuration).
|
||||||
- restoring vim sessions (optional). More details in
|
- restoring vim/neovim sessions (optional). More details in
|
||||||
[restoring vim sessions](#restoring-vim-sessions).
|
[restoring vim and neovim sessions](#restoring-vim-and-neovim-sessions).
|
||||||
- restoring bash history (optional, *experimental*). More details in
|
- restoring bash history (optional, *experimental*). More details in
|
||||||
[restoring bash history](#restoring-bash-history-experimental).
|
[restoring bash history](#restoring-bash-history-experimental).
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ You should now be able to use the plugin.
|
|||||||
Configuration is not required, but it enables extra features.
|
Configuration is not required, but it enables extra features.
|
||||||
|
|
||||||
Only a conservative list of programs is restored by default:<br/>
|
Only a conservative list of programs is restored by default:<br/>
|
||||||
`vi vim emacs man less more tail top htop irssi`.
|
`vi vim nvim emacs man less more tail top htop irssi`.
|
||||||
|
|
||||||
- Restore additional programs with the setting in `.tmux.conf`:
|
- Restore additional programs with the setting in `.tmux.conf`:
|
||||||
|
|
||||||
@ -115,15 +115,20 @@ Only a conservative list of programs is restored by default:<br/>
|
|||||||
|
|
||||||
set -g @resurrect-processes ':all:'
|
set -g @resurrect-processes ':all:'
|
||||||
|
|
||||||
#### Restoring vim sessions
|
#### Restoring vim and neovim sessions
|
||||||
|
|
||||||
- save vim sessions. I recommend [tpope/vim-obsession](https://github.com/tpope/vim-obsession).
|
- save vim/neovim sessions. I recommend
|
||||||
|
[tpope/vim-obsession](https://github.com/tpope/vim-obsession) (as almost every
|
||||||
|
plugin, it works for both vim and neovim).
|
||||||
- in `.tmux.conf`:
|
- in `.tmux.conf`:
|
||||||
|
|
||||||
|
# for vim
|
||||||
set -g @resurrect-strategy-vim 'session'
|
set -g @resurrect-strategy-vim 'session'
|
||||||
|
# for neovim
|
||||||
|
set -g @resurrect-strategy-nvim 'session'
|
||||||
|
|
||||||
`tmux-resurrect` will now restore vim sessions if `Sessions.vim` file is
|
`tmux-resurrect` will now restore vim and neovim sessions if `Sessions.vim` file
|
||||||
present.
|
is present.
|
||||||
|
|
||||||
#### Resurrect save dir
|
#### Resurrect save dir
|
||||||
|
|
||||||
@ -139,8 +144,10 @@ In `.tmux.conf`:
|
|||||||
set -g @resurrect-save-bash-history 'on'
|
set -g @resurrect-save-bash-history 'on'
|
||||||
|
|
||||||
Bash `history` for individual panes will now be saved and restored. Due to
|
Bash `history` for individual panes will now be saved and restored. Due to
|
||||||
technical limitations, this only works for panes which have Bash running in
|
technical limitations, this only works for panes which have no program running in
|
||||||
foreground (as opposed to e.g. vi or top) when saving.
|
foreground when saving. `tmux-resurrect` will send history write command
|
||||||
|
to each such pane. To prevent these commands from being added to history themselves,
|
||||||
|
add `HISTCONTROL=ignoreboth` to your `.bashrc` (this is set by default in Ubuntu).
|
||||||
|
|
||||||
### Other goodies
|
### Other goodies
|
||||||
|
|
||||||
|
@ -86,7 +86,8 @@ pane_full_command() {
|
|||||||
save_shell_history() {
|
save_shell_history() {
|
||||||
local pane_id="$1"
|
local pane_id="$1"
|
||||||
local pane_command="$2"
|
local pane_command="$2"
|
||||||
if [ "$pane_command" = "bash" ]; then
|
local full_command="$3"
|
||||||
|
if [ "$pane_command" = "bash" ] && [ "$full_command" = ":" ]; then
|
||||||
# leading space prevents the command from being saved to history
|
# leading space prevents the command from being saved to history
|
||||||
# (assuming default HISTCONTROL settings)
|
# (assuming default HISTCONTROL settings)
|
||||||
local write_command=" history -w '$(resurrect_history_file "$pane_id")'"
|
local write_command=" history -w '$(resurrect_history_file "$pane_id")'"
|
||||||
@ -121,9 +122,9 @@ dump_state() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dump_bash_history() {
|
dump_bash_history() {
|
||||||
dump_panes_raw |
|
dump_panes |
|
||||||
while IFS=$'\t' read line_type session_name window_number window_name window_active window_flags pane_index dir pane_active pane_command pane_pid; do
|
while IFS=$'\t' read line_type session_name window_number window_name window_active window_flags pane_index dir pane_active pane_command full_command; do
|
||||||
save_shell_history "$session_name:$window_number.$pane_index" "$pane_command"
|
save_shell_history "$session_name:$window_number.$pane_index" "$pane_command" "$full_command"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ restore_option="@resurrect-restore"
|
|||||||
|
|
||||||
# default processes that are restored
|
# default processes that are restored
|
||||||
default_proc_list_option="@resurrect-default-processes"
|
default_proc_list_option="@resurrect-default-processes"
|
||||||
default_proc_list='vi vim emacs man less more tail top htop irssi'
|
default_proc_list='vi vim nvim emacs man less more tail top htop irssi'
|
||||||
|
|
||||||
# User defined processes that are restored
|
# User defined processes that are restored
|
||||||
# 'false' - nothing is restored
|
# 'false' - nothing is restored
|
||||||
|
30
strategies/nvim_session.sh
Executable file
30
strategies/nvim_session.sh
Executable file
@ -0,0 +1,30 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# "nvim session strategy"
|
||||||
|
#
|
||||||
|
# Same as vim strategy, see file 'vim_session.sh'
|
||||||
|
|
||||||
|
ORIGINAL_COMMAND="$1"
|
||||||
|
DIRECTORY="$2"
|
||||||
|
|
||||||
|
nvim_session_file_exists() {
|
||||||
|
[ -e "${DIRECTORY}/Session.vim" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
original_command_contains_session_flag() {
|
||||||
|
[[ "$ORIGINAL_COMMAND" =~ "-S" ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
if nvim_session_file_exists; then
|
||||||
|
echo "nvim -S"
|
||||||
|
elif original_command_contains_session_flag; then
|
||||||
|
# Session file does not exist, yet the original nvim command contains
|
||||||
|
# session flag `-S`. This will cause an error, so we're falling back to
|
||||||
|
# starting plain nvim.
|
||||||
|
echo "nvim"
|
||||||
|
else
|
||||||
|
echo "$ORIGINAL_COMMAND"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
main
|
Reference in New Issue
Block a user