tenseleyflow/parrot / 2072737

Browse files

only run hook tip in interactive shells

Authored by espadonne
SHA
20727379c1940120f350230b22b678a8973b3b51
Parents
fd34f34
Tree
97587ab

2 changed files

StatusFile+-
M parrot-hook.fish 8 5
M parrot-hook.sh 13 5
parrot-hook.fishmodified
@@ -29,13 +29,16 @@ function parrot_postexec --on-event fish_postexec
2929
     end
3030
 end
3131
 
32
-# Setup hook (only show messages if not already initialized)
32
+# Setup hook (only show messages if not already initialized and in interactive mode)
3333
 if not set -q PARROT_INITIALIZED
34
-    echo "🦜 Parrot is now watching your fish commands..."
34
+    # Only show messages in interactive shells
35
+    if status is-interactive
36
+        echo "🦜 Parrot is now watching your fish commands..."
3537
 
36
-    # Show performance tip
37
-    if test "$PARROT_ASYNC" != "true"
38
-        echo "💡 Tip: Set PARROT_ASYNC=true to prevent terminal hangs on slow networks"
38
+        # Show performance tip
39
+        if test "$PARROT_ASYNC" != "true"
40
+            echo "💡 Tip: Set PARROT_ASYNC=true to prevent terminal hangs on slow networks"
41
+        end
3942
     end
4043
 
4144
     # Mark as initialized for this shell session
parrot-hook.shmodified
@@ -55,21 +55,29 @@ if [ -z "$PARROT_INITIALIZED" ]; then
5555
     if [ -n "$BASH_VERSION" ]; then
5656
         # Bash setup
5757
         PROMPT_COMMAND="parrot_prompt_command${PROMPT_COMMAND:+;$PROMPT_COMMAND}"
58
-        echo "🦜 Parrot is now watching your bash commands..."
58
+        # Only show message in interactive shells
59
+        if [[ $- == *i* ]]; then
60
+            echo "🦜 Parrot is now watching your bash commands..."
61
+        fi
5962
     elif [ -n "$ZSH_VERSION" ]; then
6063
         # Zsh setup
6164
         autoload -Uz add-zsh-hook
6265
         add-zsh-hook preexec parrot_preexec
6366
         add-zsh-hook precmd parrot_precmd
64
-        echo "🦜 Parrot is now watching your zsh commands..."
67
+        # Only show message in interactive shells
68
+        if [[ -o interactive ]]; then
69
+            echo "🦜 Parrot is now watching your zsh commands..."
70
+        fi
6571
     else
6672
         echo "⚠️  Parrot: Unsupported shell. Only bash, zsh, and fish are supported."
6773
         echo "💡 For fish shell, use parrot-hook.fish instead."
6874
     fi
6975
 
70
-    # Show performance tip
71
-    if [ "${PARROT_ASYNC:-}" != "true" ]; then
72
-        echo "💡 Tip: Set PARROT_ASYNC=true to prevent terminal hangs on slow networks"
76
+    # Show performance tip only in interactive shells
77
+    if [[ $- == *i* ]] || [[ -o interactive ]] 2>/dev/null; then
78
+        if [ "${PARROT_ASYNC:-}" != "true" ]; then
79
+            echo "💡 Tip: Set PARROT_ASYNC=true to prevent terminal hangs on slow networks"
80
+        fi
7381
     fi
7482
 
7583
     # Mark as initialized for this shell session