summaryrefslogtreecommitdiff
path: root/roles/shell/bash
diff options
context:
space:
mode:
Diffstat (limited to 'roles/shell/bash')
-rw-r--r--roles/shell/bash/templates/bashrc.j237
1 files changed, 37 insertions, 0 deletions
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() {
45 echo "{$FRETLINK_ENV} " 45 echo "{$FRETLINK_ENV} "
46 fi 46 fi
47} 47}
48
49function tmux_dev() {
50 type="${1:-bash}"
51 if [ -n "$TMUX" ]; then
52 m=switch-client
53 else
54 m=attach-session
55 fi
56
57 if tmux has-session -t "$type" 2>/dev/null; then
58 tmux $m -t "$type"
59 else
60 if [ "$type" = "bash" ]; then
61 tmux new-session -d -s "$type"
62 tmux $m -t "$type"
63 else
64 tmux new-session -d -c "$HOME/workdir/$type" -s "$type" \; \
65 $m -t "$type" \; \
66 send-keys "../start" C-m \; \
67 rename-window "running" \; \
68 new-window -c "$HOME/workdir/$type"
69 fi
70 fi
71}
72
73_tmux_dev() {
74 COMPREPLY=()
75 local cur="${COMP_WORDS[COMP_CWORD]}"
76 prefix="$HOME/workdir/"
77 local IFS=$'\n'
78 local items=($(compgen -W "bash" -- $cur) $(compgen -d $prefix$cur))
79 for item in ${items[@]}; do
80 [[ $item == $prefix.* ]] && continue
81 COMPREPLY+=("${item#$prefix}")
82 done
83}
84complete -o filenames -F _tmux_dev tmux_dev
48##### /Fretlink 85##### /Fretlink
49{% endif %} 86{% endif %}
50 87