.profile: Extend checks for interactive mode
authorOleg Broytman <phd@phdru.name>
Wed, 13 May 2020 07:16:40 +0000 (10:16 +0300)
committerOleg Broytman <phd@phdru.name>
Wed, 13 May 2020 07:16:40 +0000 (10:16 +0300)
Avoid starting `screen` when running under `ssh -t remote_host command`.

.profile

index b336e2a..9fce67b 100644 (file)
--- a/.profile
+++ b/.profile
@@ -305,6 +305,15 @@ fi
 #    fi
 # fi
 
+# If not running interactively, don't do anything
+case $- in
+    *i*) ;;
+      *) return ;;
+esac
+
+# Stop if non-interactive shell
+[ -z "$PS1" ] && return
+
 if [ -n "$SSH_CONNECTION" -a -z "$STY" -a -t 0 ] &&
    which screen >/dev/null 2>&1
 then