Skip to the content.

Home / cs-notes / Operating System / Linux / Shell / interactive mode

[[ $- == *i* ]] && echo "Interactive shell" || echo "Non-interactive shell"
Interactive shell

bash -c ' [[ $- == *i* ]] && echo "Interactive shell" || echo "Non-interactive shell" '
Non-interactive shell

zsh -c ' [[ $- == *i* ]] && echo "Interactive shell" || echo "Non-interactive shell" '
Non-interactive shell