From ffe9327758f121cac9ae827c8460c492c0f8c475 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Wed, 25 Apr 2012 01:01:09 +0100 Subject: [PATCH] Add various checks to print something useful when things go wrong --- layout-helpers.sh | 4 ++++ libexec/tmuxifier-new-session | 10 +++++++++- libexec/tmuxifier-new-window | 10 +++++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/layout-helpers.sh b/layout-helpers.sh index 573ae70..0cbc3b8 100644 --- a/layout-helpers.sh +++ b/layout-helpers.sh @@ -25,6 +25,8 @@ load_window() { if [[ "$window_root" != "$session_root" ]]; then window_root "$session_root" fi + else + echo "No such window layout found '$1' in '$TMUXIFIER_LAYOUT_PATH'." fi } @@ -39,6 +41,8 @@ load_session() { if [[ "$session_root" != "$HOME" ]]; then session_root="$HOME" fi + else + echo "No such session layout found '$1' in '$TMUXIFIER_LAYOUT_PATH'." fi } diff --git a/libexec/tmuxifier-new-session b/libexec/tmuxifier-new-session index a8c4170..33fef9d 100755 --- a/libexec/tmuxifier-new-session +++ b/libexec/tmuxifier-new-session @@ -26,4 +26,12 @@ fi content="$(cat "$template")" echo "${content/\{\{SESSION_NAME\}\}/$layout_name}" > "$layout_file" -exec "$EDITOR" "$layout_file" + +if [ ! -z "$EDITOR" ]; then + exec "$EDITOR" "$layout_file" +else + echo "Layout file has been created, but '\$EDITOR' is not set. Please " + echo "manually open the layout for editing:" + echo "$layout_file" + echo +fi diff --git a/libexec/tmuxifier-new-window b/libexec/tmuxifier-new-window index 1c227e1..741a592 100755 --- a/libexec/tmuxifier-new-window +++ b/libexec/tmuxifier-new-window @@ -26,4 +26,12 @@ fi content="$(cat "$template")" echo "${content/\{\{WINDOW_NAME\}\}/$layout_name}" > "$layout_file" -exec "$EDITOR" "$layout_file" + +if [ ! -z "$EDITOR" ]; then + exec "$EDITOR" "$layout_file" +else + echo "Layout file has been created, but '\$EDITOR' is not set. Please " + echo "manually open the layout for editing:" + echo "$layout_file" + echo +fi