]> git.immae.eu Git - perso/Immae/Config/Ansible.git/blobdiff - roles/shell/bash/templates/bashrc.j2
Add stgit completion
[perso/Immae/Config/Ansible.git] / roles / shell / bash / templates / bashrc.j2
index 99ed55f9919c2cb7dbcdc10069003df462e4e77e..fff19f762624f64731767fdc92db6c4f8de0d8a4 100644 (file)
@@ -29,6 +29,8 @@ alias rm="rm -i"
 alias psp="pstree -aUp $USER"
 alias dotdrop="dotdrop --cfg $XDG_CONFIG_HOME/dotdrop/config.yaml"
 
+[[ -f /usr/share/stgit/completion/stgit-completion.bash ]] && . /usr/share/stgit/completion/stgit-completion.bash
+
 {% if role.get(profile) == "fretlink" %}
 ##### Some Fretlink aliases
 alias getDump='s3cmd -c <(pass show Travail/Fretlink/S3) get '
@@ -45,6 +47,49 @@ 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
+
+  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 [ -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" \; \
+          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=($(IFS=' ' compgen -W "bash puppet" -- $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 %}