bashrc/.bashrc.d/00-shelloptions.bashrc

69 lines
1.9 KiB
Plaintext
Raw Permalink Normal View History

2023-03-18 12:49:08 +01:00
#!/usr/bin/env bash
# executed by bash(1) for non-login shells.
# ==============================
# SHELL OPTIONS
# ==============================
# shell command line style : emacs, vi, noediting
set -o emacs
# set -o vi
# set noediting
# exit will lists the status interactive jobs and postpone if one is running
shopt -s checkjobs
# includes filenames beginning with a . (dot) in pathname expansion
shopt -s dotglob
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# enable programmable completion features
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
# activate a DEBUG trap to catch term window resize
#declare -x rows cols
#update_size(){
# winsizeStatus=$(shopt | grep checkwinsize | awk '{print $2}')
# if [[ "$winsizeStatus" == "off" ]]; then
# rows=$(tput lines)
# cols=$(tput cols)
# echo -en "\e[2;5;90mDEBUG\e[25;90m TERM winsize updated to ${rows}x${cols} >\e[0m"
# else
# echo -en "\e[2;5;90mDEBUG\e[25;90m TERM winsize updated to ${LINES}x${COLUMNS} >\e[0m"
# fi
#}
#trap update_size WINCH
# ==============================
# HISTORY
# ==============================
# attempts to save all lines of a multiple-line command in the same history entry
shopt -s cmdhist
# appended rather than overwrite
shopt -s histappend
# with cmdhist, saved with embedded newlines rather than semicolon separators
shopt -s lithist
HISTCONTROL=ignoreboth
HISTSIZE=10000
HISTFILESIZE=20000
HISTTIMEFORMAT="%y/%m/%d %T "
HISTIGNORE="history:ls:l:pwd:exit:"
if [[ ${BASH_VERSION:0:1} -gt 5 || ${BASH_VERSION:0:1} -ge 5 && ${BASH_VERSION:2:1} -ge 1 ]]; then
PROMPT_COMMAND=("history -a" "history -c" "history -r")
else
PROMPT_COMMAND="history -a; history -c; history -r"
fi