Wiki

Clone wiki

git_bash_files / Auto_populate_from_History_via_up_and_down_arrow_key

A number my cohorts have started using this snippet in .bash. It enables you to auto complete as you type (with the up/down arrows) from your history;

Specifically, it looks back in time at commands you've typed that start with the text left of your cursor when hitting the up or down arrow keys.

Credit: Jason H. passed it on to me.

#-------------------------------------------------------------
# History mod from Jason H.
#-------------------------------------------------------------
# search history via up and down arrow keys
bind '"\e[A"':history-search-backward
bind '"\e[B"':history-search-forward

# Avoid duplicates in the bash command history.
export HISTCONTROL=erasedups

# Increase history size
export HISTSIZE=10000

# Append commands to the bash command history file (~/.bash_history) # instead of overwriting it. This way if you have multiple terminals open # they play nicely with the bash command history.
shopt -s histappend

# Append commands to the history every time a prompt is shown, # instead of after closing the session. This way if you have multiple # terminals open they play nicely with the bash history.
PROMPT_COMMAND='history -a'

Updated