From a65169cc0ad0e83e0febb22686e7efc250101615 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Isma=C3=ABl=20Bouya?= Date: Sat, 10 Nov 2018 08:11:16 +0100 Subject: [PATCH] Add pupper tmux session --- roles/shell/bash/templates/bashrc.j2 | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/roles/shell/bash/templates/bashrc.j2 b/roles/shell/bash/templates/bashrc.j2 index 742e1e0..2018f55 100644 --- a/roles/shell/bash/templates/bashrc.j2 +++ b/roles/shell/bash/templates/bashrc.j2 @@ -54,12 +54,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,7 +81,7 @@ _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}") -- 2.41.0