From aa8f323b8b7e3ed272e7fb5f0a18c02a875c61df Mon Sep 17 00:00:00 2001 From: Bruno Sutic Date: Tue, 26 Aug 2014 17:51:56 +0200 Subject: [PATCH] Improved handling of fields that can be empty --- scripts/session_restorer.sh | 7 ++++++- scripts/session_saver.sh | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/session_restorer.sh b/scripts/session_restorer.sh index c2dde33..5f24073 100755 --- a/scripts/session_restorer.sh +++ b/scripts/session_restorer.sh @@ -39,6 +39,10 @@ tmux_socket() { echo $TMUX | cut -d',' -f1 } +remove_first_char() { + echo "$1" | cut -c2- +} + new_window() { local session_name="$1" local window_number="$2" @@ -71,7 +75,8 @@ new_pane() { restore_pane() { local pane="$1" echo "$pane" | - while IFS=$'\t' read line_type session_name window_number dir window_name; do + while IFS=$'\t' read line_type session_name window_number window_name dir; do + window_name="$(remove_first_char $window_name)" if window_exists "$session_name" "$window_number"; then new_pane "$session_name" "$window_number" "$window_name" "$dir" elif session_exists "$session_name"; then diff --git a/scripts/session_saver.sh b/scripts/session_saver.sh index 9c93733..27525b6 100755 --- a/scripts/session_saver.sh +++ b/scripts/session_saver.sh @@ -13,9 +13,9 @@ pane_format() { format+="${delimiter}" format+="#{window_index}" format+="${delimiter}" - format+="#{pane_current_path}" + format+=":#{window_name}" format+="${delimiter}" - format+="#{window_name}" + format+="#{pane_current_path}" echo "$format" }