qnd:bash_configuration

Bash Configuration

Some handy bash configuration for .bashrc

#
# This setting allows a command to be recalled from history, but not immediately executed.
# This allows the command to be modified before being executed.
#
shopt -s histverify
# Exclude things from being saved in history
export HISTIGNORE="history*:[ \tbf]g*:hh:hs:jobs:fc:clear:man *"
# Prevent duplicate entries
export HISTCONTROL=ignoreboth:erasedups
# When the shell exits, append to the history file instead of overwriting it
shopt -s histappend
# Add date-time stamp for commands in history output
export HISTTIMEFORMAT="%F %T "
#
# Add current line to history without executing it.
#
bind '"\C-q": "\C-a history -s \C-j"'
 
#
# Bind the keyboard combination Alt + h to displaying the command history.
#
# bind '"\eh":" history | sort -nr | less\n"'
bind -x '"\eh":" history | sort -nr | less"'
# bind '"\ew":" jobs\n"'
bind -x '"\ew":" jobs"'
#
# Disable flow control, so Ctrl + s can be used for forward searches in history to go with reverse searches (Ctrl + r)
#
stty -ixon
 
alias ll='ls -haltr --color'
alias grep='grep -i'
alias hh='history | sort -nr | less'
alias hg='history | grep'
alias nn='nano'
alias ha='history -a'
alias hs='history -s'
# Handle saving history with multiple shells
# After each command, append to the history file and reread it
# Ref: https://unix.stackexchange.com/questions/1288/preserve-bash-history-in-multiple-terminal-windows
PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a; history -c; history -r"
  • qnd/bash_configuration.txt
  • Last modified: 2023/03/31 11:34
  • by mgupton