User option for disabling pane process restoring

This commit is contained in:
Bruno Sutic 2014-08-27 13:12:32 +02:00
parent cbf58ac613
commit 7f50660918
No known key found for this signature in database
GPG Key ID: 66D96E4F2F7EF26C
3 changed files with 31 additions and 8 deletions

View File

@ -2,6 +2,7 @@
### master ### master
- restore pane processes - restore pane processes
- user option for disabling pane process restoring
### v0.0.4, 2014-08-26 ### v0.0.4, 2014-08-26
- restore pane layout for each window - restore pane layout for each window

View File

@ -1,6 +1,9 @@
# configurable constants # configurable constants
default_sessions_dir="$HOME/.tmux/sessions" default_sessions_dir="$HOME/.tmux/sessions"
sessions_dir_option="@sessions-dir" sessions_dir_option="@session-saver-dir"
restore_processes_option="@session-saver-restore-processes"
default_restore_processes="true"
SUPPORTED_VERSION="1.9" SUPPORTED_VERSION="1.9"

View File

@ -105,14 +105,33 @@ restore_all_sessions() {
done < $(last_session_path) done < $(last_session_path)
} }
restore_pane_processes_enabled() {
local restore_processes="$(get_tmux_option "$restore_processes_option" "$default_restore_processes")"
if [ $restore_processes == "false" ]; then
return 1
else
return 0
fi
}
restore_pane_process() {
local pane_full_command="$1"
local session_name="$2"
local window_number="$3"
local pane_index="$4"
tmux switch-client -t "${session_name}:${window_number}"
tmux send-keys -t "$pane_index" "$pane_full_command" "C-m"
}
restore_all_pane_processes() { restore_all_pane_processes() {
if restore_pane_processes_enabled; then
local pane_full_command local pane_full_command
awk 'BEGIN { FS="\t"; OFS="\t" } /^pane/ && $11 !~ "^:$" { print $2, $3, $7, $11; }' $(last_session_path) | awk 'BEGIN { FS="\t"; OFS="\t" } /^pane/ && $11 !~ "^:$" { print $2, $3, $7, $11; }' $(last_session_path) |
while IFS=$'\t' read session_name window_number pane_index pane_full_command; do while IFS=$'\t' read session_name window_number pane_index pane_full_command; do
pane_full_command="$(remove_first_char "$pane_full_command")" pane_full_command="$(remove_first_char "$pane_full_command")"
tmux switch-client -t "${session_name}:${window_number}" restore_pane_process "$pane_full_command" "$session_name" "$window_number" "$pane_index"
tmux send-keys -t "$pane_index" "$pane_full_command" "C-m"
done done
fi
} }
restore_pane_layout_for_each_window() { restore_pane_layout_for_each_window() {