only run hook tip in interactive shells
- SHA
20727379c1940120f350230b22b678a8973b3b51- Parents
-
fd34f34 - Tree
97587ab
2072737
20727379c1940120f350230b22b678a8973b3b51fd34f34
97587ab| Status | File | + | - |
|---|---|---|---|
| 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 | ||
| 29 | 29 | end |
| 30 | 30 | end |
| 31 | 31 | |
| 32 | -# Setup hook (only show messages if not already initialized) | |
| 32 | +# Setup hook (only show messages if not already initialized and in interactive mode) | |
| 33 | 33 | 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..." | |
| 35 | 37 | |
| 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 | |
| 39 | 42 | end |
| 40 | 43 | |
| 41 | 44 | # Mark as initialized for this shell session |
parrot-hook.shmodified@@ -55,21 +55,29 @@ if [ -z "$PARROT_INITIALIZED" ]; then | ||
| 55 | 55 | if [ -n "$BASH_VERSION" ]; then |
| 56 | 56 | # Bash setup |
| 57 | 57 | 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 | |
| 59 | 62 | elif [ -n "$ZSH_VERSION" ]; then |
| 60 | 63 | # Zsh setup |
| 61 | 64 | autoload -Uz add-zsh-hook |
| 62 | 65 | add-zsh-hook preexec parrot_preexec |
| 63 | 66 | 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 | |
| 65 | 71 | else |
| 66 | 72 | echo "⚠️ Parrot: Unsupported shell. Only bash, zsh, and fish are supported." |
| 67 | 73 | echo "💡 For fish shell, use parrot-hook.fish instead." |
| 68 | 74 | fi |
| 69 | 75 | |
| 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 | |
| 73 | 81 | fi |
| 74 | 82 | |
| 75 | 83 | # Mark as initialized for this shell session |