mirror of
https://github.com/tmux-plugins/tmux-resurrect.git
synced 2024-11-22 12:38:47 +00:00
parent
a649614a20
commit
8051fb9d36
@ -1,6 +1,7 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
### master
|
### master
|
||||||
|
- restore pane layout for each window
|
||||||
|
|
||||||
### v0.0.3, 2014-08-26
|
### v0.0.3, 2014-08-26
|
||||||
- save and restore current and alternate session
|
- save and restore current and alternate session
|
||||||
|
@ -104,6 +104,13 @@ restore_all_sessions() {
|
|||||||
done < $(last_session_path)
|
done < $(last_session_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
restore_pane_layout_for_each_window() {
|
||||||
|
\grep '^window' $(last_session_path) |
|
||||||
|
while IFS=$'\t' read line_type session_name window_number window_active window_flags window_layout; do
|
||||||
|
tmux select-layout -t "${session_name}:${window_number}" "$window_layout"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
restore_active_pane_for_each_window() {
|
restore_active_pane_for_each_window() {
|
||||||
awk 'BEGIN { FS="\t"; OFS="\t" } /^pane/ && $7 != 0 && $9 == 1 { print $2, $3, $7; }' $(last_session_path) |
|
awk 'BEGIN { FS="\t"; OFS="\t" } /^pane/ && $7 != 0 && $9 == 1 { print $2, $3, $7; }' $(last_session_path) |
|
||||||
while IFS=$'\t' read session_name window_number active_pane; do
|
while IFS=$'\t' read session_name window_number active_pane; do
|
||||||
@ -132,6 +139,7 @@ main() {
|
|||||||
if supported_tmux_version_ok; then
|
if supported_tmux_version_ok; then
|
||||||
check_saved_session_exists
|
check_saved_session_exists
|
||||||
restore_all_sessions
|
restore_all_sessions
|
||||||
|
restore_pane_layout_for_each_window
|
||||||
restore_active_pane_for_each_window
|
restore_active_pane_for_each_window
|
||||||
restore_active_and_alternate_windows
|
restore_active_and_alternate_windows
|
||||||
restore_active_and_alternate_sessions
|
restore_active_and_alternate_sessions
|
||||||
|
@ -27,6 +27,23 @@ pane_format() {
|
|||||||
echo "$format"
|
echo "$format"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window_format() {
|
||||||
|
local delimiter=$'\t'
|
||||||
|
local format
|
||||||
|
format+="window"
|
||||||
|
format+="${delimiter}"
|
||||||
|
format+="#{session_name}"
|
||||||
|
format+="${delimiter}"
|
||||||
|
format+="#{window_index}"
|
||||||
|
format+="${delimiter}"
|
||||||
|
format+="#{window_active}"
|
||||||
|
format+="${delimiter}"
|
||||||
|
format+=":#{window_flags}"
|
||||||
|
format+="${delimiter}"
|
||||||
|
format+="#{window_layout}"
|
||||||
|
echo "$format"
|
||||||
|
}
|
||||||
|
|
||||||
state_format() {
|
state_format() {
|
||||||
local delimiter=$'\t'
|
local delimiter=$'\t'
|
||||||
local format
|
local format
|
||||||
@ -42,6 +59,10 @@ dump_panes() {
|
|||||||
tmux list-panes -a -F "$(pane_format)"
|
tmux list-panes -a -F "$(pane_format)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dump_windows() {
|
||||||
|
tmux list-windows -a -F "$(window_format)"
|
||||||
|
}
|
||||||
|
|
||||||
dump_state() {
|
dump_state() {
|
||||||
tmux display-message -p "$(state_format)"
|
tmux display-message -p "$(state_format)"
|
||||||
}
|
}
|
||||||
@ -49,8 +70,9 @@ dump_state() {
|
|||||||
save_all_sessions() {
|
save_all_sessions() {
|
||||||
local session_path="$(session_path)"
|
local session_path="$(session_path)"
|
||||||
mkdir -p "$(sessions_dir)"
|
mkdir -p "$(sessions_dir)"
|
||||||
dump_panes > $session_path
|
dump_panes > $session_path
|
||||||
dump_state >> $session_path
|
dump_windows >> $session_path
|
||||||
|
dump_state >> $session_path
|
||||||
ln -fs "$session_path" "$(last_session_path)"
|
ln -fs "$session_path" "$(last_session_path)"
|
||||||
display_message "Saved all Tmux sessions!"
|
display_message "Saved all Tmux sessions!"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user