@@ -217,6 +217,24 @@ rc.local example | |||
# 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 | |||
------------- |
@@ -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 %} |
@@ -45,3 +45,6 @@ include: | |||
{%- if system.limit|length > 0 %} | |||
- linux.system.limit | |||
{%- endif %} | |||
{%- if system.prompt is defined %} | |||
- linux.system.prompt | |||
{%- endif %} |
@@ -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 %} |