5 Commits

Author SHA1 Message Date
e770c87e10 v1.5.0 2014-11-09 16:43:44 +01:00
601366be6d Support for restoring neovim sessions 2014-11-09 16:42:53 +01:00
059686ab6c Merge pull request #55 from rburny/master
Fixes to #51 and #52
2014-10-26 16:59:41 +01:00
488f086fa5 Add a note about HISTCONTROL to README. 2014-10-26 02:17:12 +02:00
fcf7ca13f0 Only save pane history if its not running any program (other than Bash
shell). Fixes a bug where 'history -w' was sent to pane running Bash
script.
2014-10-26 01:30:00 +02:00
5 changed files with 56 additions and 15 deletions

View File

@ -2,6 +2,9 @@
### master
### v1.5.0, 2014-11-09
- add support for restoring neovim sessions
### v1.4.0, 2014-10-25
- plugin now uses strategies when fetching pane full command. Implemented
'default' strategy.

View File

@ -12,7 +12,7 @@ projects.
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.
It even (optionally) [restores vim sessions](#restoring-vim-sessions)!
It even (optionally) [restores vim and neovim sessions](#restoring-vim-and-neovim-sessions)!
### 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
- programs running within a pane! More details in the
[configuration section](#configuration).
- restoring vim sessions (optional). More details in
[restoring vim sessions](#restoring-vim-sessions).
- restoring vim/neovim sessions (optional). More details in
[restoring vim and neovim sessions](#restoring-vim-and-neovim-sessions).
- restoring bash history (optional, *experimental*). More details in
[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.
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`:
@ -115,15 +115,20 @@ Only a conservative list of programs is restored by default:<br/>
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`:
# for vim
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
present.
`tmux-resurrect` will now restore vim and neovim sessions if `Sessions.vim` file
is present.
#### Resurrect save dir
@ -139,8 +144,10 @@ In `.tmux.conf`:
set -g @resurrect-save-bash-history 'on'
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
foreground (as opposed to e.g. vi or top) when saving.
technical limitations, this only works for panes which have no program running in
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

View File

@ -86,7 +86,8 @@ pane_full_command() {
save_shell_history() {
local pane_id="$1"
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
# (assuming default HISTCONTROL settings)
local write_command=" history -w '$(resurrect_history_file "$pane_id")'"
@ -121,9 +122,9 @@ dump_state() {
}
dump_bash_history() {
dump_panes_raw |
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
save_shell_history "$session_name:$window_number.$pane_index" "$pane_command"
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 full_command; do
save_shell_history "$session_name:$window_number.$pane_index" "$pane_command" "$full_command"
done
}

View File

@ -7,7 +7,7 @@ restore_option="@resurrect-restore"
# default processes that are restored
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
# 'false' - nothing is restored

30
strategies/nvim_session.sh Executable file
View 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