--- /dev/null
+#!/bin/bash
+
+_fl_tmux_dev() {
+ COMPREPLY=()
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ prefix="$HOME/workdir/"
+ local IFS=$'\n'
+ local items=($(IFS=' ' compgen -W "bash remote puppet" -- $cur) $(compgen -d $prefix$cur))
+ for item in ${items[@]}; do
+ [[ $item == $prefix.* ]] && continue
+ COMPREPLY+=("${item#$prefix}")
+ done
+}
+complete -o filenames -F _fl_tmux_dev fl_tmux_dev
--- /dev/null
+#!/bin/bash
+
+type="${1:-bash}"
+if [ -n "$TMUX" ]; then
+ m=switch-client
+else
+ m=attach-session
+fi
+
+case "$type" in
+ "bash") start_dir="$HOME";;
+ "remote") 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" = "remote" ]; then
+ tmux new-session -d -c $start_dir -s "$type" mosh immae.eu \; \
+ $m -t "$type"
+ elif [ -n "$start_dir" ]; then
+ tmux new-session -d -c $start_dir -s "$type" \; \
+ $m -t "$type" \; \
+ new-window -c $start_dir
+ elif [ -d "$HOME/workdir/$type" ]; then
+ 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"
+ else
+ echo "Unknown session" >&2
+ exit 1
+ fi
+fi
scope: user
name: remind@work.service
enabled: true
+- name: scripts
+ block:
+ - name: completion directory
+ file:
+ state: directory
+ path: $XDG_DATA_HOME/bash_completion
+ - name: scripts
+ copy:
+ mode: 0755
+ src: "scripts/{{ item }}"
+ dest: "$HOME/.local/bin/{{ item }}"
+ loop:
+ - fl_tmux_dev
+ - fl_vpn
+ - fl_getDump
+ - name: completion scripts
+ copy:
+ src: "scripts/_{{ item }}"
+ dest: "$XDG_DATA_HOME/bash_completion/_{{ item }}"
+ loop:
+ - fl_tmux_dev
[[ -f /usr/share/stgit/completion/stgit-completion.bash ]] && . /usr/share/stgit/completion/stgit-completion.bash
+if [[ -d "$XDG_DATA_HOME/bash_completion" ]]; then
+ for i in $XDG_DATA_HOME/bash_completion/*; do
+ [[ -f "$i" && -r "$i" ]] && . "$i"
+ done
+fi
+
{% if role.get(profile) == "fretlink" %}
##### Some Fretlink aliases
-alias getDump='s3cmd -c <(pass show Travail/Fretlink/S3) get '
-
-function vpn() {
- TMPFILE=$(mktemp /tmp/openvpn.XXXXXX)
- pass show Travail/Fretlink/OpenVPN >> $TMPFILE
- sudo openvpn $TMPFILE
- rm -f $TMPFILE
-}
+alias vpn=fl_vpn
+alias tmux_dev=fl_tmux_dev
+complete -o filenames -F _fl_tmux_dev tmux_dev
function dev_prompt() {
if [ -n "$FRETLINK_ENV" ]; then
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";;
- "remote") 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" = "remote" ]; then
- tmux new-session -d -c $start_dir -s "$type" mosh immae.eu \; \
- $m -t "$type"
- elif [ -n "$start_dir" ]; then
- tmux new-session -d -c $start_dir -s "$type" \; \
- $m -t "$type" \; \
- new-window -c $start_dir
- elif [ -d "$HOME/workdir/$type" ]; then
- 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"
- else
- echo "Unknown session" >&2
- false
- fi
- fi
-}
-
-_tmux_dev() {
- COMPREPLY=()
- local cur="${COMP_WORDS[COMP_CWORD]}"
- prefix="$HOME/workdir/"
- local IFS=$'\n'
- local items=($(IFS=' ' compgen -W "bash remote 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
-
if [ -n "$TMUX" ]; then
TMUX_SESSION_NAME=$(tmux display-message -p "#S")
export HISTFILE="$XDG_STATE_HOME/bash/tmux_${TMUX_SESSION_NAME}_history"