if [[ -o login ]]; then
echo "I'm a login shell"
fi
if [[ -o interactive ]]; then
echo "I'm interactive"
fi
[[ -o the-option ]] returns true if the-option is set.
You can also get the values of options with the $options special associative array, or by running set -o.
To check if there's an ssh-agent:
if [[ -w $SSH_AUTH_SOCK ]]; then
echo "there's one"
fi
In ksh (and zsh):
case $- in (*i*) echo interactive; esac
case $- in (*l*) echo login; esac
In bash, it's a mess, you need:
case $- in *i*) echo interactive; esac # that should work in any Bourne/POSIX shell
case :$BASHOPTS: in (*:login_shell:*) echo login; esac
And $SHELLOPTS contains some more options. Some options you can set with set -<x>, some with set -o option, some with shopt -s option.