diff options
author | Ismaël Bouya <ismael.bouya@fretlink.com> | 2018-11-08 09:47:19 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@fretlink.com> | 2018-11-08 09:47:19 +0100 |
commit | de1c634c1fda61e34522595b40c66af17681bd14 (patch) | |
tree | 115addd5065cf8e2817ebbac744625489107988e | |
parent | 78ae9604c629fcfadbbcb70ae743068ea6d40278 (diff) | |
download | Ansible-de1c634c1fda61e34522595b40c66af17681bd14.tar.gz Ansible-de1c634c1fda61e34522595b40c66af17681bd14.tar.zst Ansible-de1c634c1fda61e34522595b40c66af17681bd14.zip |
Add a tmux_dev command
-rw-r--r-- | roles/shell/bash/templates/bashrc.j2 | 37 | ||||
-rw-r--r-- | roles/tools/templates/tmux.conf.j2 | 21 |
2 files changed, 37 insertions, 21 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 | |||
49 | function 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 | } | ||
84 | complete -o filenames -F _tmux_dev tmux_dev | ||
48 | ##### /Fretlink | 85 | ##### /Fretlink |
49 | {% endif %} | 86 | {% endif %} |
50 | 87 | ||
diff --git a/roles/tools/templates/tmux.conf.j2 b/roles/tools/templates/tmux.conf.j2 index 8aad615..a7ac4ce 100644 --- a/roles/tools/templates/tmux.conf.j2 +++ b/roles/tools/templates/tmux.conf.j2 | |||
@@ -65,24 +65,3 @@ set-window-option -g window-status-bell-style fg=yellow,bold,underscore | |||
65 | set -g default-terminal screen-256color | 65 | set -g default-terminal screen-256color |
66 | 66 | ||
67 | set -g mouse on | 67 | set -g mouse on |
68 | |||
69 | {% if role.get(profile) == "fretlink" %} | ||
70 | new-session -A -c "$HOME/workdir/admin-root" -s admin-root | ||
71 | send-keys "../start" C-m | ||
72 | rename-window "running" | ||
73 | new-window | ||
74 | new-session -A -c "$HOME/workdir/carrier-directory" -s carrier-directory | ||
75 | send-keys "../start" C-m | ||
76 | rename-window "running" | ||
77 | new-window | ||
78 | new-session -A -c "$HOME/workdir/notifier" -s notifier | ||
79 | send-keys "../start" C-m | ||
80 | rename-window "running" | ||
81 | new-window | ||
82 | new-session -A -c "$HOME/workdir/geodata" -s geodata | ||
83 | new-session -A -c "$HOME/workdir/app" -s app | ||
84 | send-keys "../start" C-m | ||
85 | rename-window "running" | ||
86 | new-window | ||
87 | select-window -t 1 | ||
88 | {% endif %} | ||