Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
2edd3ff98d | |||
bcad7cd1ea | |||
4d5c0a2a0d | |||
8051fb9d36 |
@ -2,6 +2,10 @@
|
||||
|
||||
### master
|
||||
|
||||
### v0.0.4, 2014-08-26
|
||||
- restore pane layout for each window
|
||||
- bugfix: correct pane ordering in a window
|
||||
|
||||
### v0.0.3, 2014-08-26
|
||||
- save and restore current and alternate session
|
||||
- fix a bug with non-existing window names
|
||||
|
@ -69,7 +69,7 @@ new_pane() {
|
||||
local window_number="$2"
|
||||
local window_name="$3"
|
||||
local dir="$4"
|
||||
tmux split-window -d -t "${session_name}:${window_number}" -c "$dir"
|
||||
tmux split-window -t "${session_name}:${window_number}" -c "$dir"
|
||||
}
|
||||
|
||||
restore_pane() {
|
||||
@ -104,6 +104,13 @@ restore_all_sessions() {
|
||||
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() {
|
||||
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
|
||||
@ -113,7 +120,7 @@ restore_active_pane_for_each_window() {
|
||||
}
|
||||
|
||||
restore_active_and_alternate_windows() {
|
||||
awk 'BEGIN { FS="\t"; OFS="\t" } /^pane/ && $6 ~ /[*-]/ { print $2, $5, $3; }' $(last_session_path) |
|
||||
awk 'BEGIN { FS="\t"; OFS="\t" } /^window/ && $5 ~ /[*-]/ { print $2, $4, $3; }' $(last_session_path) |
|
||||
sort -u |
|
||||
while IFS=$'\t' read session_name active_window window_number; do
|
||||
tmux switch-client -t "${session_name}:${window_number}"
|
||||
@ -132,6 +139,7 @@ main() {
|
||||
if supported_tmux_version_ok; then
|
||||
check_saved_session_exists
|
||||
restore_all_sessions
|
||||
restore_pane_layout_for_each_window
|
||||
restore_active_pane_for_each_window
|
||||
restore_active_and_alternate_windows
|
||||
restore_active_and_alternate_sessions
|
||||
|
@ -27,6 +27,23 @@ pane_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() {
|
||||
local delimiter=$'\t'
|
||||
local format
|
||||
@ -42,6 +59,10 @@ dump_panes() {
|
||||
tmux list-panes -a -F "$(pane_format)"
|
||||
}
|
||||
|
||||
dump_windows() {
|
||||
tmux list-windows -a -F "$(window_format)"
|
||||
}
|
||||
|
||||
dump_state() {
|
||||
tmux display-message -p "$(state_format)"
|
||||
}
|
||||
@ -49,8 +70,9 @@ dump_state() {
|
||||
save_all_sessions() {
|
||||
local session_path="$(session_path)"
|
||||
mkdir -p "$(sessions_dir)"
|
||||
dump_panes > $session_path
|
||||
dump_state >> $session_path
|
||||
dump_panes > $session_path
|
||||
dump_windows >> $session_path
|
||||
dump_state >> $session_path
|
||||
ln -fs "$session_path" "$(last_session_path)"
|
||||
display_message "Saved all Tmux sessions!"
|
||||
}
|
||||
|
Reference in New Issue
Block a user