diff --git a/README.md b/README.md index ea94871..f0a2f99 100644 --- a/README.md +++ b/README.md @@ -139,8 +139,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 diff --git a/scripts/save.sh b/scripts/save.sh index e54a0ce..ebfdd54 100755 --- a/scripts/save.sh +++ b/scripts/save.sh @@ -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 }