X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=roles%2Fshell%2Fbash%2Ftemplates%2Fbashrc.j2;h=742e1e02e6c79fc5d35f3930580502f98879bb24;hb=de1c634c1fda61e34522595b40c66af17681bd14;hp=99ed55f9919c2cb7dbcdc10069003df462e4e77e;hpb=78ae9604c629fcfadbbcb70ae743068ea6d40278;p=perso%2FImmae%2FConfig%2FAnsible.git diff --git a/roles/shell/bash/templates/bashrc.j2 b/roles/shell/bash/templates/bashrc.j2 index 99ed55f..742e1e0 100644 --- a/roles/shell/bash/templates/bashrc.j2 +++ b/roles/shell/bash/templates/bashrc.j2 @@ -45,6 +45,43 @@ function dev_prompt() { echo "{$FRETLINK_ENV} " fi } + +function tmux_dev() { + type="${1:-bash}" + if [ -n "$TMUX" ]; then + m=switch-client + else + m=attach-session + fi + + 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" + else + tmux new-session -d -c "$HOME/workdir/$type" -s "$type" \; \ + $m -t "$type" \; \ + send-keys "../start" C-m \; \ + rename-window "running" \; \ + new-window -c "$HOME/workdir/$type" + fi + fi +} + +_tmux_dev() { + COMPREPLY=() + local cur="${COMP_WORDS[COMP_CWORD]}" + prefix="$HOME/workdir/" + local IFS=$'\n' + local items=($(compgen -W "bash" -- $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 ##### /Fretlink {% endif %}