Improved handling of fields that can be empty

This commit is contained in:
Bruno Sutic 2014-08-26 17:51:56 +02:00
parent c78a38803a
commit aa8f323b8b
No known key found for this signature in database
GPG Key ID: 66D96E4F2F7EF26C
2 changed files with 8 additions and 3 deletions

View File

@ -39,6 +39,10 @@ tmux_socket() {
echo $TMUX | cut -d',' -f1 echo $TMUX | cut -d',' -f1
} }
remove_first_char() {
echo "$1" | cut -c2-
}
new_window() { new_window() {
local session_name="$1" local session_name="$1"
local window_number="$2" local window_number="$2"
@ -71,7 +75,8 @@ new_pane() {
restore_pane() { restore_pane() {
local pane="$1" local pane="$1"
echo "$pane" | 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 if window_exists "$session_name" "$window_number"; then
new_pane "$session_name" "$window_number" "$window_name" "$dir" new_pane "$session_name" "$window_number" "$window_name" "$dir"
elif session_exists "$session_name"; then elif session_exists "$session_name"; then

View File

@ -13,9 +13,9 @@ pane_format() {
format+="${delimiter}" format+="${delimiter}"
format+="#{window_index}" format+="#{window_index}"
format+="${delimiter}" format+="${delimiter}"
format+="#{pane_current_path}" format+=":#{window_name}"
format+="${delimiter}" format+="${delimiter}"
format+="#{window_name}" format+="#{pane_current_path}"
echo "$format" echo "$format"
} }