Procházet zdrojové kódy

Option to preserve bash history

tags/2016.12
Filip Pytloun před 8 roky
rodič
revize
eef11c1aa0
4 změnil soubory, kde provedl 39 přidání a 0 odebrání
  1. +13
    -0
      README.rst
  2. +12
    -0
      linux/files/bash_history.sh
  3. +11
    -0
      linux/system/bash.sls
  4. +3
    -0
      linux/system/init.sls

+ 13
- 0
README.rst Zobrazit soubor

@@ -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
~~~~~~~~~~~~~~~~~~


+ 12
- 0
linux/files/bash_history.sh Zobrazit soubor

@@ -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

+ 11
- 0
linux/system/bash.sls Zobrazit soubor

@@ -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 %}

+ 3
- 0
linux/system/init.sls Zobrazit soubor

@@ -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 %}

Načítá se…
Zrušit
Uložit