X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=roles%2Fshell%2Fbash%2Ftemplates%2Fbashrc.j2;h=fabe53fb5ec63f80d0a0529f23a2e1b8bb8ac9fd;hb=bfe7d9cb1f547161cb7c7f4924c62c6ef819e4d7;hp=742e1e02e6c79fc5d35f3930580502f98879bb24;hpb=de1c634c1fda61e34522595b40c66af17681bd14;p=perso%2FImmae%2FConfig%2FAnsible.git diff --git a/roles/shell/bash/templates/bashrc.j2 b/roles/shell/bash/templates/bashrc.j2 index 742e1e0..fabe53f 100644 --- a/roles/shell/bash/templates/bashrc.j2 +++ b/roles/shell/bash/templates/bashrc.j2 @@ -2,7 +2,7 @@ # ~/.bashrc # -[[ -f "$HOME/.bashrc_temp" ]] && . $HOME/.bashrc_temp +[[ -f "$XDG_STATE_HOME/bash/bashrc_temp" ]] && . $XDG_STATE_HOME/bash/bashrc_temp if [ -n "$HOME/.local/bin" ]; then PATH="$HOME/.local/bin:$PATH" @@ -29,6 +29,8 @@ alias rm="rm -i" alias psp="pstree -aUp $USER" alias dotdrop="dotdrop --cfg $XDG_CONFIG_HOME/dotdrop/config.yaml" +[[ -f /usr/share/stgit/completion/stgit-completion.bash ]] && . /usr/share/stgit/completion/stgit-completion.bash + {% if role.get(profile) == "fretlink" %} ##### Some Fretlink aliases alias getDump='s3cmd -c <(pass show Travail/Fretlink/S3) get ' @@ -54,12 +56,18 @@ function tmux_dev() { m=attach-session fi + case "$type" in + "bash") 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 [ "$type" = "bash" ]; then - tmux new-session -d -s "$type" - tmux $m -t "$type" + if [ -n "$start_dir" ]; then + tmux new-session -d -c $start_dir -s "$type" \; \ + $m -t "$type" \; \ + new-window -c $start_dir else tmux new-session -d -c "$HOME/workdir/$type" -s "$type" \; \ $m -t "$type" \; \ @@ -75,13 +83,18 @@ _tmux_dev() { local cur="${COMP_WORDS[COMP_CWORD]}" prefix="$HOME/workdir/" local IFS=$'\n' - local items=($(compgen -W "bash" -- $cur) $(compgen -d $prefix$cur)) + local items=($(IFS=' ' compgen -W "bash puppet" -- $cur) $(compgen -d $prefix$cur)) for item in ${items[@]}; do [[ $item == $prefix.* ]] && continue COMPREPLY+=("${item#$prefix}") done } complete -o filenames -F _tmux_dev tmux_dev + +if [ -n "$TMUX" ]; then + TMUX_SESSION_NAME=$(tmux display-message -p "#S") + export HISTFILE="$XDG_STATE_HOME/bash/tmux_${TMUX_SESSION_NAME}_history" +fi ##### /Fretlink {% endif %} @@ -129,6 +142,8 @@ PS1='\[\033[01;31m\]$(error_code)\[\033[00;00m\]$(running_jobs)\[\033[01;32m\]$( 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 %} +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 {% endif %}