> For the complete documentation index, see [llms.txt](https://woodrowpearson.gitbook.io/code-gists/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://woodrowpearson.gitbook.io/code-gists/bash/is-this-shell-interactive-bash-reference-manual.md).

# Is this Shell Interactive? (Bash Reference Manual)

## 6.3.2 Is this Shell Interactive?

To determine within a startup script whether or not Bash is running interactively, test the value of the ‘-’ special parameter. It contains `i` when the shell is interactive. For example:

```
case "$-" in
*i*)	echo This shell is interactive ;;
*)	echo This shell is not interactive ;;
esac
```

Alternatively, startup scripts may examine the variable `PS1`; it is unset in non-interactive shells, and set in interactive shells. Thus:

```
if [ -z "$PS1" ]; then
        echo This shell is not interactive
else
        echo This shell is interactive
fi
```
