@@ -267,6 +267,19 @@ PS1 in ``/etc/bash.bashrc`` and ``~/.bashrc`` (which comes from | |||
``/etc/skel/.bashrc``). This formula will do this automatically, but will not | |||
touch existing user's ``~/.bashrc`` files except root. | |||
Bash | |||
~~~~ | |||
Fix bash configuration to preserve history across sessions (like ZSH does by | |||
default). | |||
.. code-block:: yaml | |||
linux: | |||
system: | |||
bash: | |||
preserve_history: true | |||
Message of the day | |||
~~~~~~~~~~~~~~~~~~ | |||
@@ -0,0 +1,12 @@ | |||
{%- from "linux/map.jinja" import system with context %} | |||
# History across sessions for Bash | |||
if [ -n "$BASH_VERSION" ]; then | |||
# Avoid duplicates | |||
export HISTCONTROL=ignoredups:erasedups | |||
# When the shell exits, append to the history file instead of overwriting it | |||
shopt -s histappend | |||
# After each command, append to the history file and reread it | |||
export PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a; history -c; history -r" | |||
fi |
@@ -0,0 +1,11 @@ | |||
{%- from "linux/map.jinja" import system with context %} | |||
{%- if system.enabled %} | |||
{%- if system.bash.get('preserve_history', False) %} | |||
/etc/profile.d/bash_history.sh: | |||
file.managed: | |||
- source: salt://linux/files/bash_history.sh | |||
- template: jinja | |||
{%- endif %} | |||
{%- endif %} |
@@ -18,6 +18,9 @@ include: | |||
{%- if system.prompt is defined %} | |||
- linux.system.prompt | |||
{%- endif %} | |||
{%- if system.bash is defined %} | |||
- linux.system.bash | |||
{%- endif %} | |||
{%- if system.user|length > 0 %} | |||
- linux.system.user | |||
{%- endif %} |