Proposal to hide the input commands saving/restoring bash history:

First, the following must be configured in your ~/.bashrc:
bind -x '"\C-[z": tput smcut'  # Enter a secondary terminal buffer with Alt-z
bind -x '"\C-[Z": tput rmcut'  # Quit it with Alt-Z

Then the tmux sent keys can include those controls around the executed
commands to invisibly save/restore the history.
pull/295/head
Guillaume LOUVEL 2019-03-27 18:53:02 +01:00
parent 8fcb4ab40b
commit 9d5d28f353
2 changed files with 3 additions and 4 deletions

View File

@ -281,7 +281,7 @@ restore_shell_history() {
if [ "$pane_command" = "bash" ]; then
local read_command="history -r '$history_file'"
tmux send-keys -t "$pane_id" "$read_command" C-m
tmux send-keys -t "$pane_id" M-z "$read_command" C-m M-Z
elif [ "$pane_command" = "zsh" ]; then
local accept_line="$(expr "$(zsh -i -c bindkey | grep -m1 '\saccept-line$')" : '^"\(.*\)".*')"
local read_command="fc -R '$history_file'; clear"

View File

@ -176,9 +176,8 @@ save_shell_history() {
local read_command=" $history_r '$(resurrect_history_file "$pane_id" "$pane_command")'"
# C-e C-u is a Bash shortcut sequence to clear whole line. It is necessary to
# delete any pending input so it does not interfere with our history command.
tmux send-keys -t "$pane_id" "$end_of_line" "$backward_kill_line" "$write_command" "$accept_line"
# Immediately restore after saving
tmux send-keys -t "$pane_id" "$end_of_line" "$backward_kill_line" "$read_command" "$accept_line"
# and immediately restore after saving
tmux send-keys -t "$pane_id" "$end_of_line" "$backward_kill_line" M-z "$write_command;$read_command" "$accept_line" M-Z
fi
}