Unverified Commit 7f506609 authored by Bruno Sutic's avatar Bruno Sutic
Browse files

User option for disabling pane process restoring

parent cbf58ac6
......@@ -2,6 +2,7 @@
### master
- restore pane processes
- user option for disabling pane process restoring
### v0.0.4, 2014-08-26
- restore pane layout for each window
......
# configurable constants
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"
......
......@@ -105,14 +105,33 @@ restore_all_sessions() {
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() {
local pane_full_command
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
pane_full_command="$(remove_first_char "$pane_full_command")"
tmux switch-client -t "${session_name}:${window_number}"
tmux send-keys -t "$pane_index" "$pane_full_command" "C-m"
done
if restore_pane_processes_enabled; then
local pane_full_command
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
pane_full_command="$(remove_first_char "$pane_full_command")"
restore_pane_process "$pane_full_command" "$session_name" "$window_number" "$pane_index"
done
fi
}
restore_pane_layout_for_each_window() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment