2022-01-15 19:00:35 +09:00
|
|
|
#! bash oh-my-bash.module
|
2017-03-19 17:13:00 +07:00
|
|
|
shopt -s histappend # append to bash_history if Terminal.app quits
|
|
|
|
|
2017-03-19 15:40:25 +07:00
|
|
|
## Command history configuration
|
|
|
|
if [ -z "$HISTFILE" ]; then
|
2019-01-23 03:05:32 -08:00
|
|
|
HISTFILE=$HOME/.bash_history
|
2017-03-19 15:40:25 +07:00
|
|
|
fi
|
|
|
|
|
2019-01-23 03:05:32 -08:00
|
|
|
|
|
|
|
# some moderate history controls taken from sensible.bash
|
|
|
|
## SANE HISTORY DEFAULTS ##
|
|
|
|
|
|
|
|
# Append to the history file, don't overwrite it
|
|
|
|
shopt -s histappend
|
|
|
|
|
|
|
|
# Save multi-line commands as one command
|
|
|
|
shopt -s cmdhist
|
|
|
|
|
2022-06-23 11:03:11 +09:00
|
|
|
# Re-edit the command line for failing history expansions
|
2019-01-23 03:05:32 -08:00
|
|
|
shopt -s histreedit
|
|
|
|
|
2022-06-23 11:03:11 +09:00
|
|
|
# Re-edit the result of history expansions
|
2019-01-23 03:05:32 -08:00
|
|
|
shopt -s histverify
|
|
|
|
|
|
|
|
# save history with newlines instead of ; where possible
|
|
|
|
shopt -s lithist
|
|
|
|
|
|
|
|
# Record each line as it gets issued
|
2022-01-11 12:40:43 +09:00
|
|
|
_omb_util_add_prompt_command 'history -a'
|
2019-01-23 03:05:32 -08:00
|
|
|
|
2022-06-23 11:03:11 +09:00
|
|
|
# Unlimited history size. Doesn't appear to slow things down, so why not?
|
|
|
|
# Export these variables to apply them also to the child shell sessions.
|
|
|
|
export HISTSIZE=
|
|
|
|
export HISTFILESIZE=
|
2019-01-23 03:05:32 -08:00
|
|
|
|
|
|
|
# Avoid duplicate entries
|
|
|
|
HISTCONTROL="erasedups:ignoreboth"
|
|
|
|
|
|
|
|
# Don't record some commands
|
|
|
|
export HISTIGNORE="&:[ ]*:exit:ls:bg:fg:history:clear"
|
|
|
|
|
|
|
|
# Enable incremental history search with up/down arrows (also Readline goodness)
|
|
|
|
# Learn more about this here: http://codeinthehole.com/writing/the-most-important-command-line-tip-incremental-hi
|
|
|
|
# bash4 specific ??
|
|
|
|
bind '"\e[A": history-search-backward'
|
|
|
|
bind '"\e[B": history-search-forward'
|
|
|
|
bind '"\e[C": forward-char'
|
|
|
|
bind '"\e[D": backward-char'
|
2017-03-19 15:40:25 +07:00
|
|
|
|
2021-07-29 00:12:00 -03:00
|
|
|
# Use standard ISO 8601 timestamp
|
|
|
|
# %F equivalent to %Y-%m-%d
|
|
|
|
# %T equivalent to %H:%M:%S (24-hours format)
|
|
|
|
|
2017-03-19 15:40:25 +07:00
|
|
|
# Show history
|
2021-07-29 00:12:00 -03:00
|
|
|
case $HIST_STAMPS in
|
2021-09-10 11:28:42 -03:00
|
|
|
"mm/dd/yyyy") HISTTIMEFORMAT=$'\033[31m[%m/%d/%Y] \033[36m[%T]\033[0m ' ;;
|
2022-09-29 18:16:28 +09:00
|
|
|
"dd.mm.yyyy") HISTTIMEFORMAT=$'\033[31m[%d.%m.%Y] \033[36m[%T]\033[0m ' ;;
|
|
|
|
"yyyy-mm-dd") HISTTIMEFORMAT=$'\033[31m[%F] \033[36m[%T]\033[0m ' ;;
|
2021-09-10 11:28:42 -03:00
|
|
|
*) HISTTIMEFORMAT=$'\033[31m%F \033[36m%T\033[0m ' ;;
|
2021-07-29 00:12:00 -03:00
|
|
|
esac
|