File descriptor

0: stdin; 1: stdout; 2: stderr ; 3-9: custom

2>&1 >/dev/null # Merges stderr into the stdout | POSIX-compliant
&>/dev/null     # bash/Zsh shortcut , fail if sh->dash
ssh-add 2>/dev/null

Login & Interactive

Shell Type Profiles Common Scenarios
I L /etc/profile &&
~/( .bash_profile(. .bashrc) or .bash_login or .profile )
• SSH session into a remote server (ssh user@host)
• Local TTY/console login (Ctrl+Alt+F3)
• Running bash --login or su - username
Non-I L same as above
skip interactive features
• Remote command execution via SSH (ssh user@host "ls -la")
• Automated deployment scripts requiring full login environment
I Non-L /etc/{bash.bashrc or /etc/bashrc} && ~/.bashrc • Opening a new terminal window or tab in a GUI desktop
• Running bash inside an existing terminal session
• Terminal inside IDEs (VS Code, JetBrains)
Non-I Non-L $BASH_ENV ; no load profiles • Executing a shell script (./script.sh or sh script.sh)
• Automated scheduled tasks (cron jobs, systemd services)
• CI/CD pipeline step execution

login shells:
- exit: ~/.bash_logout

Non-Interactive Non-Login Shell: - Does NOT load /etc/profile, ~/.bash_profile, or ~/.bashrc. - $BASH_ENV — If this environment variable is set, Bash expands its value and executes the file named there before running the script.

# shopt -q login_shell && echo login_shell # more reliable than $0 "-"

# su - root
# echo $0 : `shopt login_shell` \| $-
-bash : login_shell on | himBHs

# bash -l
# echo $0 : `shopt login_shell` \| $-
bash : login_shell on | himBHs

# bash
# echo $0 : `shopt login_shell` \| $-
bash : login_shell off | himBHs

# bash -c 'echo $0 : `shopt login_shell` \| $-'
bash : login_shell off | hBc

https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html

Bash

https://www.gnu.org/software/bash/manual/bash.html

url=https://raw.githubusercontent.com/fzinfz/scripts/master/init.sh # alias & functions
source /dev/stdin <<< "$(curl -sS $url)"

set
    -x                      debug
    -T                      If  set, any traps on DEBUG and RETURN are inherited
    -o functrace/errtrace

shopt [-pqsu] [-o] [optname …]
    -s/u: set/unset each optname
    -p: print status of all optname # or `shopt` without args

shopt -s expand_aliases     # when the shell is not interactive
alias foo='...'

https://git.savannah.gnu.org/cgit/bash.git/

Tools - Online

http://explainshell.com/

tmux

ctrl+b x -> kill pane   # /usr/share/doc/tmux/examples/screen-keys.conf
cat /usr/share/doc/tmux/examples/screen-keys.conf | grep '\bbind \w'