diff --git a/autoattach b/autoattach index 9179920..718f2e2 100755 --- a/autoattach +++ b/autoattach @@ -14,12 +14,26 @@ function write_setting fi } +function is_tmux_running +{ + if [ -n "${TMUX}" ]; then + return 0 + fi + return 1 +} + +function debug +{ + if ! is_tmux_running; then + echo $1 + fi +} function attach_session { - if [ -n "${TMUX}" ]; then - exit 1 - fi + if is_tmux_running; then + exit 0 + fi tmux attach -t $1 2> /dev/null @@ -61,7 +75,6 @@ function usage exit 0 } - # Load configuration file test -f $CONF_FILE && . $CONF_FILE @@ -70,8 +83,8 @@ PLATFORM='unknown' unamestr=$(uname) case "$unamestr" in OpenBSD* ) - echo "*BSD OS detected!!" - echo "Long options is disabled!!" + debug "*BSD OS detected!!" + debug "Long options is disabled!!" OPTS=`getopt chgs: $*` set_opts_exit_status=$? PLATFORM=$unamestr ;;