X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=roles%2Fshell%2Fbash%2Ftemplates%2Fbashrc.j2;h=1bf94e7d3064f90a5bba7d94c44f0f80a0206d15;hb=80ed46d46999eff6a89f26622d4dd4900e3b2ce6;hp=c7f85224b579b28d436bc72eda2924e655b35df3;hpb=b7b8fe64fb3ed13ef535c7d4789da3a5001e355d;p=perso%2FImmae%2FConfig%2FAnsible.git diff --git a/roles/shell/bash/templates/bashrc.j2 b/roles/shell/bash/templates/bashrc.j2 index c7f8522..1bf94e7 100644 --- a/roles/shell/bash/templates/bashrc.j2 +++ b/roles/shell/bash/templates/bashrc.j2 @@ -90,32 +90,40 @@ function git_prompt() { } {% set ps1_git = '\[$(git_prompt_color)\]$(git_prompt)' %} -function error_code() { - ret=$? - if [[ $ret != 0 ]]; then - echo "$ret " - fi -} - function running_jobs() { ret=$(jobs | wc -l) if [[ $ret != 0 ]]; then echo "[$ret] " fi } -{% set ps1_status = '\[\\033[01;31m\]$(error_code)\[\\033[00;00m\]$(running_jobs)' -%} -{# Ensure new line before the prompt #} -{% set ps1_newline = '$(printf "%$((`tput cols`-1))s\\r")' -%} +PROMPT_COMMAND=__prompt_command -{% set ps1_other = '' %} -{% if role.get(profile) == "fretlink" -%} - {% set ps1_other = '\[\\033[01;32m\]$(dev_prompt)' %} -{%- endif %} +__prompt_command () { + local ret="$?" + PS1="" + d="\[\033[00;00m\]" + red="\[\033[01;31m\]" + bgreen="\[\033[01;32m\]" + green="\[\033[00;32m\]" + blue="\[\033[94m\]" -PS1='{{ ps1_newline }}{{ ps1_status }}{{ ps1_other }}{{ ps1_git }}\[\033[00;32m\]\u@\h\[\033[94m\] \w \$\[\033[00m\] ' + # Ensure new line before the prompt + PS1='$(printf "%$((`tput cols`-1))s\r")' + if [[ $ret != 0 ]]; then + PS1+="$red$ret $d" + fi + PS1+='$(running_jobs)' +{% if role.get(profile) == "fretlink" %} + PS1+="$bgreen"'$(dev_prompt)' +{% endif %} + PS1+='\[$(git_prompt_color)\]$(git_prompt)' + PS1+="$green\u@\h$blue \w \$$d " +} -PROMPT_COMMAND="[[ -f $XDG_STATE_HOME/bash/bashrc_temp ]] && . $XDG_STATE_HOME/bash/bashrc_temp" +source /usr/share/fzf/key-bindings.bash +source /usr/share/fzf/completion.bash +export FZF_COMPLETION_TRIGGER='#' {% if "nodejs" in features.get(profile, []) %} source /usr/share/nvm/init-nvm.sh