]> git.immae.eu Git - perso/Immae/Config/Ansible.git/blobdiff - roles/shell/bash/templates/bashrc.j2
Make bash xdg-compliant
[perso/Immae/Config/Ansible.git] / roles / shell / bash / templates / bashrc.j2
index 08518c9dca101e731573bb85154913c7c132c9d4..b717f0ed66e237f41fc7b6d6d54ab848559b5d80 100644 (file)
@@ -27,7 +27,7 @@ alias mv="mv -i"
 alias cp="cp -i"
 alias rm="rm -i"
 alias psp="pstree -aUp $USER"
-alias dotdrop="dotdrop --cfg $XDG_CONFIG_HOME/dotdrop/config.yaml"
+alias info='info -v active-link-style=yellow,bold -v link-style=yellow'
 
 [[ -f /usr/share/stgit/completion/stgit-completion.bash ]] && . /usr/share/stgit/completion/stgit-completion.bash
 
@@ -125,6 +125,7 @@ function git_prompt() {
     echo -e "($gitinfo) "
   fi
 }
+{% set ps1_git = '\[$(git_prompt_color)\]$(git_prompt)' %}
 
 function error_code() {
   ret=$?
@@ -139,14 +140,19 @@ function running_jobs() {
     echo "[$ret] "
   fi
 }
+{% set ps1_status = '\[\\033[01;31m\]$(error_code)\[\\033[00;00m\]$(running_jobs)' -%}
 
-{% if role.get(profile) == "fretlink" %}
-PS1='\[\033[01;31m\]$(error_code)\[\033[00;00m\]$(running_jobs)\[\033[01;32m\]$(dev_prompt)\[$(git_prompt_color)\]$(git_prompt)\[\033[00;32m\]\u@\h\[\033[94m\] \w \$\[\033[00m\] '
-{% else %}
-PS1='\[\033[01;31m\]$(error_code)\[\033[00;00m\]$(running_jobs)\[$(git_prompt_color)\]$(git_prompt)\[\033[00;32m\]\u@\h\[\033[94m\] \w \$\[\033[00m\] '
-{% endif %}
+{# Ensure new line before the prompt #}
+{% set ps1_newline = '$(printf "%$((`tput cols`-1))s\\r")' -%}
+
+{% set ps1_other = '' %}
+{% if role.get(profile) == "fretlink" -%}
+  {% set ps1_other = '\[\\033[01;32m\]$(dev_prompt)' %}
+{%- endif %}
+
+PS1='{{ ps1_newline }}{{ ps1_status }}{{ ps1_other }}{{ ps1_git }}\[\033[00;32m\]\u@\h\[\033[94m\] \w \$\[\033[00m\] '
 
-PROMPT_COMMAND="[[ -f "$XDG_STATE_HOME/bash/bashrc_temp" ]] && . $XDG_STATE_HOME/bash/bashrc_temp"
+PROMPT_COMMAND="[[ -f $XDG_STATE_HOME/bash/bashrc_temp ]] && . $XDG_STATE_HOME/bash/bashrc_temp"
 
 {% if "nodejs" in features.get(profile, []) %}
 source /usr/share/nvm/init-nvm.sh