X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=roles%2Fshell%2Fbash%2Ftemplates%2Fbashrc.j2;h=91311e5eb8060276f668f48d138c6f83f3f74782;hb=dd308b2f8fdd6cfb2aec4778c347a7d156a0d754;hp=fabe53fb5ec63f80d0a0529f23a2e1b8bb8ac9fd;hpb=bfe7d9cb1f547161cb7c7f4924c62c6ef819e4d7;p=perso%2FImmae%2FConfig%2FAnsible.git diff --git a/roles/shell/bash/templates/bashrc.j2 b/roles/shell/bash/templates/bashrc.j2 index fabe53f..91311e5 100644 --- a/roles/shell/bash/templates/bashrc.j2 +++ b/roles/shell/bash/templates/bashrc.j2 @@ -13,6 +13,8 @@ fi export GPG_TTY=$(tty) export HISTFILE="$XDG_STATE_HOME/bash/history" +export HISTTIMEFORMAT='%F %T ' +export HISTCONTROL="ignorespace:ignoredups" alias vi=vim alias ls='ls --color=auto -F -T 0' @@ -27,7 +29,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 @@ -58,13 +60,17 @@ function tmux_dev() { case "$type" in "bash") start_dir="$HOME";; + "remote") start_dir="$HOME";; "puppet") start_dir="/etc/puppetlabs/code" esac if tmux has-session -t "$type" 2>/dev/null; then tmux $m -t "$type" else - if [ -n "$start_dir" ]; then + if [ "$type" = "remote" ]; then + tmux new-session -d -c $start_dir -s "$type" mosh immae.eu \; \ + $m -t "$type" + elif [ -n "$start_dir" ]; then tmux new-session -d -c $start_dir -s "$type" \; \ $m -t "$type" \; \ new-window -c $start_dir @@ -83,7 +89,7 @@ _tmux_dev() { local cur="${COMP_WORDS[COMP_CWORD]}" prefix="$HOME/workdir/" local IFS=$'\n' - local items=($(IFS=' ' compgen -W "bash puppet" -- $cur) $(compgen -d $prefix$cur)) + local items=($(IFS=' ' compgen -W "bash remote puppet" -- $cur) $(compgen -d $prefix$cur)) for item in ${items[@]}; do [[ $item == $prefix.* ]] && continue COMPREPLY+=("${item#$prefix}") @@ -121,6 +127,7 @@ function git_prompt() { echo -e "($gitinfo) " fi } +{% set ps1_git = '\[$(git_prompt_color)\]$(git_prompt)' %} function error_code() { ret=$? @@ -135,14 +142,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