Allow setting system-wide prompt
diff --git a/README.rst b/README.rst
index f9df956..f5146e6 100644
--- a/README.rst
+++ b/README.rst
@@ -217,6 +217,24 @@
# By default this script does nothing.
exit 0
+Prompt
+~~~~~~
+
+Setting prompt is implemented by creating ``/etc/profile.d/prompt.sh``. Every
+user can have different prompt.
+
+.. code-block:: yaml
+
+ linux:
+ system:
+ prompt:
+ root: \\n\\[\\033[0;37m\\]\\D{%y/%m/%d %H:%M:%S} $(hostname -f)\\[\\e[0m\\]\\n\\[\\e[1;31m\\][\\u@\\h:\\w]\\[\\e[0m\\]
+ default: \\n\\D{%y/%m/%d %H:%M:%S} $(hostname -f)\\n[\\u@\\h:\\w]
+
+On Debian systems to set prompt system-wide it's necessary to remove setting
+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.
Linux network
-------------
diff --git a/linux/files/prompt.sh b/linux/files/prompt.sh
new file mode 100644
index 0000000..aee9780
--- /dev/null
+++ b/linux/files/prompt.sh
@@ -0,0 +1,20 @@
+{%- from "linux/map.jinja" import system with context %}
+
+# Don't set special prompt when not using Bash or ZSH
+[ -n "$BASH_VERSION" -o -n "$ZSH_VERSION" ] || return 0
+
+# Don't set prompt on non-interactive shell
+[[ $- == *i* ]] || return 0
+
+{%- for user, prompt in system.prompt.iteritems() %}
+{% if user != default %}
+if [ "$USERNAME" == "{{ user }}" ]; then
+ export PS1="{{ prompt }} "
+ return 0
+fi
+{% endif %}
+{%- endfor %}
+
+{% if system.prompt.default is defined %}
+export PS1="{{ system.prompt.default }} "
+{%- endif %}
diff --git a/linux/system/init.sls b/linux/system/init.sls
index dc09bee..bfaf460 100644
--- a/linux/system/init.sls
+++ b/linux/system/init.sls
@@ -45,3 +45,6 @@
{%- if system.limit|length > 0 %}
- linux.system.limit
{%- endif %}
+{%- if system.prompt is defined %}
+- linux.system.prompt
+{%- endif %}
diff --git a/linux/system/prompt.sls b/linux/system/prompt.sls
new file mode 100644
index 0000000..eba96d7
--- /dev/null
+++ b/linux/system/prompt.sls
@@ -0,0 +1,19 @@
+{%- from "linux/map.jinja" import system with context %}
+{%- if system.enabled %}
+
+/etc/profile.d/prompt.sh:
+ file.managed:
+ - source: salt://linux/files/prompt.sh
+ - template: jinja
+
+/etc/bash.bashrc:
+ file.replace:
+ - pattern: ".*PS1=.*"
+ - repl: "# Prompt is set by /etc/profile.d/prompt.sh"
+
+/etc/skel/.bashrc:
+ file.replace:
+ - pattern: ".*PS1=.*"
+ - repl: "# Prompt is set by /etc/profile.d/prompt.sh"
+
+{%- endif %}