If you want to autocomplete shell commands, with up-arrow, by looking at the history of similar executed commands…plus some extra tweaking, keep reading.
2 – Solution
Add to your .bashrc file the following lines
# Autocomplete with up-arrow# To avoid bind warning on remote pcscase"$TERM" in
esac#see: http://aplawrence.com/Linux/bash_history.html# … and keep multi line commands togethershopt -s cmdhist
#Real-time history export amongst bash terminal windows (stackoverflow)export HISTCONTROL=ignoredups:erasedups # no duplicate entriesexport HISTSIZE=100000 # big big historyexport HISTFILESIZE=100000 # big big historyshopt -s histappend # append to history, don't overwrite it# Save and reload the history after each command finishes#export PROMPT_COMMAND="history -n; history -a; history -c; history -r; $PROMPT_COMMAND"export PROMPT_COMMAND="history -n; history -w; history -c; history -r; $PROMPT_COMMAND"# Please be very careful with CTRL-s. On many terminals it stops the output # and your session will appear to be frozen! If that happens, use CTRL-q to # unfreeze it. You may want to remove CTRL+s mapping from your terminal altogether. # Add "stty stop ''" to your shell startup file (.bashrc for bash, .kshrc for ksh, etc).stty stop ''
If you don’t have a .bashrc file, you can create it by typing in a linux shell
Then copy-paste the above snippet add press :w and then ENTER to save the file.
Finally, source your .bashrc file in order to see the results ;)