Implemented buffer restore with write to pane tty.

pull/62/head
Mark Eissler 2014-12-10 14:14:27 -08:00
parent 93a53a7995
commit a1d70359c4
2 changed files with 22 additions and 3 deletions

View File

@ -15,6 +15,18 @@ get_tmux_option() {
fi
}
get_pane_id() {
tmux display-message -p "#S:#I.#P"
}
get_pane_tty() {
local pane_id="$1"
[[ -z "$1" ]] && pane_id="$(get_pane_id)"
# display tty for pane_id
tmux display-message -t "$pane_id" -p "#{pane_tty}"
}
# Ensures a message is displayed for 5 seconds in tmux prompt.
# Does not override the 'display-time' tmux option.
display_message() {

View File

@ -162,12 +162,19 @@ restore_tmux_buffers() {
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"
local buffer_file="$(resurrect_buffer_file "${pane_id}")"
local buffer_file="$(resurrect_buffer_file "$pane_id")"
# space before 'cat' is intentional and prevents the command from
# being added to history (provided HISTCONTROL=ignorespace/ignoreboth
# has been set in bashrc.
tmux send-keys -t "${pane_id}" "clear && tmux clear-history" C-m
tmux send-keys -t "${pane_id}" " cat ${buffer_file}" C-m
tmux send-keys -t "$pane_id" " clear && tmux clear-history" C-m
local pane_tty="$(get_pane_tty "$pane_id")"
if [ -n "$pane_tty" ]; then
# append directly to tty (avoids cat command output)
cat "$buffer_file" >> "$pane_tty"
else
# fall back to cat'ing in terminal if not tty found
tmux send-keys -t "$pane_id" " cat \"$buffer_file\"" C-m
fi
fi
fi
done