summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@fretlink.com>2018-11-18 13:08:53 +0100
committerIsmaël Bouya <ismael.bouya@fretlink.com>2018-11-18 13:20:49 +0100
commit1f22cde1b4257989d92877f1cc83a2b81e26981c (patch)
tree4fe51fe2b00e8d5e4cb2e21105619e14edd9b5c3
parentbfe7d9cb1f547161cb7c7f4924c62c6ef819e4d7 (diff)
downloadAnsible-1f22cde1b4257989d92877f1cc83a2b81e26981c.tar.gz
Ansible-1f22cde1b4257989d92877f1cc83a2b81e26981c.tar.zst
Ansible-1f22cde1b4257989d92877f1cc83a2b81e26981c.zip
Add remote session for tmux
-rw-r--r--roles/shell/bash/files/bashrc1
-rw-r--r--roles/shell/bash/templates/bashrc.j28
2 files changed, 6 insertions, 3 deletions
diff --git a/roles/shell/bash/files/bashrc b/roles/shell/bash/files/bashrc
deleted file mode 100644
index 28d0af9..0000000
--- a/roles/shell/bash/files/bashrc
+++ /dev/null
@@ -1 +0,0 @@
1coucou
diff --git a/roles/shell/bash/templates/bashrc.j2 b/roles/shell/bash/templates/bashrc.j2
index fabe53f..08518c9 100644
--- a/roles/shell/bash/templates/bashrc.j2
+++ b/roles/shell/bash/templates/bashrc.j2
@@ -58,13 +58,17 @@ function tmux_dev() {
58 58
59 case "$type" in 59 case "$type" in
60 "bash") start_dir="$HOME";; 60 "bash") start_dir="$HOME";;
61 "remote") start_dir="$HOME";;
61 "puppet") start_dir="/etc/puppetlabs/code" 62 "puppet") start_dir="/etc/puppetlabs/code"
62 esac 63 esac
63 64
64 if tmux has-session -t "$type" 2>/dev/null; then 65 if tmux has-session -t "$type" 2>/dev/null; then
65 tmux $m -t "$type" 66 tmux $m -t "$type"
66 else 67 else
67 if [ -n "$start_dir" ]; then 68 if [ "$type" = "remote" ]; then
69 tmux new-session -d -c $start_dir -s "$type" mosh immae.eu \; \
70 $m -t "$type"
71 elif [ -n "$start_dir" ]; then
68 tmux new-session -d -c $start_dir -s "$type" \; \ 72 tmux new-session -d -c $start_dir -s "$type" \; \
69 $m -t "$type" \; \ 73 $m -t "$type" \; \
70 new-window -c $start_dir 74 new-window -c $start_dir
@@ -83,7 +87,7 @@ _tmux_dev() {
83 local cur="${COMP_WORDS[COMP_CWORD]}" 87 local cur="${COMP_WORDS[COMP_CWORD]}"
84 prefix="$HOME/workdir/" 88 prefix="$HOME/workdir/"
85 local IFS=$'\n' 89 local IFS=$'\n'
86 local items=($(IFS=' ' compgen -W "bash puppet" -- $cur) $(compgen -d $prefix$cur)) 90 local items=($(IFS=' ' compgen -W "bash remote puppet" -- $cur) $(compgen -d $prefix$cur))
87 for item in ${items[@]}; do 91 for item in ${items[@]}; do
88 [[ $item == $prefix.* ]] && continue 92 [[ $item == $prefix.* ]] && continue
89 COMPREPLY+=("${item#$prefix}") 93 COMPREPLY+=("${item#$prefix}")