theme/nwinkler: adopt automatic history
Use `preexec` and `$HISTCONTROL` to configure _Bash It_'s automatic history management feature.pull/1951/head
parent
7823e36d15
commit
569b8b8c46
|
|
@ -16,6 +16,18 @@
|
|||
# since 'fasd' is messing with the $PROMPT_COMMAND
|
||||
|
||||
|
||||
case $HISTCONTROL in
|
||||
*'auto'*)
|
||||
: # Do nothing, already configured.
|
||||
;;
|
||||
*)
|
||||
# Append new history lines to history file
|
||||
HISTCONTROL="${HISTCONTROL:-}${HISTCONTROL:+:}autosave"
|
||||
;;
|
||||
esac
|
||||
safe_append_preexec '_bash-it-history-auto-load'
|
||||
safe_append_prompt_command '_bash-it-history-auto-save'
|
||||
|
||||
PROMPT_END_CLEAN="${green}→${reset_color}"
|
||||
PROMPT_END_DIRTY="${red}→${reset_color}"
|
||||
|
||||
|
|
@ -28,8 +40,6 @@ prompt_setter() {
|
|||
if [[ $exit_status -eq 0 ]]; then PROMPT_END=$PROMPT_END_CLEAN
|
||||
else PROMPT_END=$PROMPT_END_DIRTY
|
||||
fi
|
||||
# Save history
|
||||
_save-and-reload-history 1
|
||||
PS1="($(clock_prompt)) $(scm_char) [${blue}\u${reset_color}@${green}\H${reset_color}] ${yellow}\w${reset_color}$(scm_prompt_info) ${reset_color}\n$(prompt_end) "
|
||||
PS2='> '
|
||||
PS4='+ '
|
||||
|
|
|
|||
|
|
@ -95,13 +95,23 @@ prompt_setter() {
|
|||
if [[ $exit_status -eq 0 ]]; then PROMPT_END=$PROMPT_END_CLEAN
|
||||
else PROMPT_END=$PROMPT_END_DIRTY
|
||||
fi
|
||||
# Save history
|
||||
_save-and-reload-history 1
|
||||
PS1="($(clock_prompt)${reset_color}) $(scm_char) [${USERNAME_COLOR}\u${reset_color}@${HOSTNAME_COLOR}\H${reset_color}] ${PATH_COLOR}\w${reset_color}$(scm_prompt_info) ${reset_color}\n$(prompt_end) "
|
||||
PS2='> '
|
||||
PS4='+ '
|
||||
}
|
||||
|
||||
case $HISTCONTROL in
|
||||
*'auto'*)
|
||||
: # Do nothing, already configured.
|
||||
;;
|
||||
*)
|
||||
# Append new history lines to history file
|
||||
HISTCONTROL="${HISTCONTROL:-}${HISTCONTROL:+:}autosave"
|
||||
;;
|
||||
esac
|
||||
safe_append_preexec '_bash-it-history-auto-load'
|
||||
safe_append_prompt_command '_bash-it-history-auto-save'
|
||||
|
||||
safe_append_prompt_command prompt_setter
|
||||
|
||||
SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗${normal}"
|
||||
|
|
|
|||
Loading…
Reference in New Issue