From 5d98199bf9d37b56eb7c0c72dd9e8a95139176b7 Mon Sep 17 00:00:00 2001 From: Michael Krayer Date: Fri, 26 Mar 2021 15:00:32 +0100 Subject: [PATCH] when called without mode argument now, the script returns the status of attach --- session | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/session b/session index 4484e8b..138d20a 100755 --- a/session +++ b/session @@ -171,15 +171,20 @@ print_scrollback() { } ## Parse first argument (= mode argument) -if [[ "$#" -lt 1 ]]; then - print_help - exit $EXIT_INVALID_MODE -fi mode=$1 shift ## Now enter mode specific code case $mode in + "") + if [ -z "$DTACH_SESSION_NAME" ];then + echo "Currently not attached." + exit $EXIT_NOT_ATTACHED + else + echo "Currently attached to '$DTACH_SESSION_NAME'." + exit $EXIT_SUCCESS + fi + ;; "attach"|"att"|"a") exit_if_in_session # If no session name specified: select interactively @@ -204,7 +209,7 @@ case $mode in session_path=$(get_session_path $session_name) CMD="dtach -a $session_path -e ${config[detach_char]} -r winch " #echo $CMD - echo "[attached to $session_name]" + echo "[attached to '$session_name']" [[ "${config[log_session]}" == "yes" ]] && print_scrollback $session_name eval $CMD exit $EXITSUCCESS @@ -231,7 +236,7 @@ case $mode in CMD+="/bin/bash" fi #echo $CMD - echo "[new session $session_name]" + echo "[new session '$session_name']" eval $CMD exit $EXITSUCCESS ;;