Skip to content

set

Read and write variables


List all enviroment variables

set

Abort on nonzero exitstatus

set -o errexit

abort on unbound variable

set -o nounset

Don't hide errors within pipes

set -o pipefail

Disable all history from bash_history and "history" command

Add below to /etc/profile

vim ~/.bashrc
set +o history
export HISTFILE=/dev/null
export HISTSIZE=0
export HISTFILESIZE=0
source ~/.bashrc

Show all available commands that is being used when using a shell command

bash -x somecommand

Exit immediately if a pipeline returns a non-zero status

set -o errexit

Trap ERR from shell functions, command substitutions, and commands from subshell

set -o errtrace

Treat unset variables as an error

set -o nounset

Pipe will exit with last non-zero status, if applicable

set -o pipefail

Shorthand for above (pipefail has no short option)

set -Eue -o pipefail

Save bash history permanent

##### Bash History Configuration #####

HISTFILE="$HOME/.bash_history"
HISTSIZE=1000000
HISTFILESIZE=2000000
HISTTIMEFORMAT='%F %T - '

shopt -s histappend

# Save and reload history after every command
PROMPT_COMMAND='history -a; history -n'

# Optional controls
HISTCONTROL=ignoreboth
HISTIGNORE='ls:cd:pwd:exit:clear'