mirror of
https://github.com/tmux-plugins/tmux-resurrect.git
synced 2025-09-10 21:23:09 +00:00
Add bash history saving and restoring (first version).
This does not yet have flag to turn the feature off.
This commit is contained in:

committed by
Bruno Sutic

parent
a73c465e47
commit
81982b5114
@ -141,6 +141,21 @@ restore_all_panes() {
|
||||
done < $(last_resurrect_file)
|
||||
}
|
||||
|
||||
restore_shell_history() {
|
||||
awk 'BEGIN { FS="\t"; OFS="\t" } /^pane/ { print $2, $3, $7, $10; }' $(last_resurrect_file) |
|
||||
while IFS=$'\t' read session_name window_number pane_index pane_command; do
|
||||
if ! is_pane_registered_as_existing "$session_name" "$window_number" "$pane_index"; then
|
||||
if [ "$pane_command" = "bash" ]; then
|
||||
local pane_id="$session_name:$window_number.$pane_index"
|
||||
# tmux send-keys has -R option that should reset the terminal.
|
||||
# However, appending 'clear' to the command seems to work more reliably.
|
||||
local read_command="history -r '$(resurrect_history_file "$pane_id")'; clear"
|
||||
tmux send-keys -t "$pane_id" "$read_command" C-m
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
restore_all_pane_processes() {
|
||||
if restore_pane_processes_enabled; then
|
||||
local pane_full_command
|
||||
@ -196,6 +211,7 @@ main() {
|
||||
start_spinner "Restoring..." "Tmux restore complete!"
|
||||
restore_all_panes
|
||||
restore_pane_layout_for_each_window >/dev/null 2>&1
|
||||
restore_shell_history
|
||||
restore_all_pane_processes
|
||||
# below functions restore exact cursor positions
|
||||
restore_active_pane_for_each_window
|
||||
|
Reference in New Issue
Block a user