josephwecker / bashrc_dispatch

Launch different bash configurations for Linux vs OSX, interactive vs batch
137 stars 9 forks source link

Use $- to determine if interactive #3

Closed gaelicWizard closed 3 years ago

gaelicWizard commented 3 years ago

Instead of checking for environment variable $PS1 (which could be blindly set by a user or script somewhere), ask Bash if it is interactive by interrogating $- automatic variable. If it contains 'i' then the shell was started interactively.