summaryrefslogtreecommitdiff
path: root/roles/shell/bash/templates/bashrc.j2
diff options
context:
space:
mode:
Diffstat (limited to 'roles/shell/bash/templates/bashrc.j2')
-rw-r--r--roles/shell/bash/templates/bashrc.j267
1 files changed, 9 insertions, 58 deletions
diff --git a/roles/shell/bash/templates/bashrc.j2 b/roles/shell/bash/templates/bashrc.j2
index bf5acfa..0dc80c0 100644
--- a/roles/shell/bash/templates/bashrc.j2
+++ b/roles/shell/bash/templates/bashrc.j2
@@ -33,16 +33,17 @@ alias info='info -v active-link-style=yellow,bold -v link-style=yellow'
33 33
34[[ -f /usr/share/stgit/completion/stgit-completion.bash ]] && . /usr/share/stgit/completion/stgit-completion.bash 34[[ -f /usr/share/stgit/completion/stgit-completion.bash ]] && . /usr/share/stgit/completion/stgit-completion.bash
35 35
36if [[ -d "$XDG_DATA_HOME/bash_completion" ]]; then
37 for i in $XDG_DATA_HOME/bash_completion/*; do
38 [[ -f "$i" && -r "$i" ]] && . "$i"
39 done
40fi
41
36{% if role.get(profile) == "fretlink" %} 42{% if role.get(profile) == "fretlink" %}
37##### Some Fretlink aliases 43##### Some Fretlink aliases
38alias getDump='s3cmd -c <(pass show Travail/Fretlink/S3) get ' 44alias vpn=fl_vpn
39 45alias tmux_dev=fl_tmux_dev
40function vpn() { 46complete -o filenames -F _fl_tmux_dev tmux_dev
41 TMPFILE=$(mktemp /tmp/openvpn.XXXXXX)
42 pass show Travail/Fretlink/OpenVPN >> $TMPFILE
43 sudo openvpn $TMPFILE
44 rm -f $TMPFILE
45}
46 47
47function dev_prompt() { 48function dev_prompt() {
48 if [ -n "$FRETLINK_ENV" ]; then 49 if [ -n "$FRETLINK_ENV" ]; then
@@ -50,56 +51,6 @@ function dev_prompt() {
50 fi 51 fi
51} 52}
52 53
53function tmux_dev() {
54 type="${1:-bash}"
55 if [ -n "$TMUX" ]; then
56 m=switch-client
57 else
58 m=attach-session
59 fi
60
61 case "$type" in
62 "bash") start_dir="$HOME";;
63 "remote") start_dir="$HOME";;
64 "puppet") start_dir="/etc/puppetlabs/code"
65 esac
66
67 if tmux has-session -t "$type" 2>/dev/null; then
68 tmux $m -t "$type"
69 else
70 if [ "$type" = "remote" ]; then
71 tmux new-session -d -c $start_dir -s "$type" mosh immae.eu \; \
72 $m -t "$type"
73 elif [ -n "$start_dir" ]; then
74 tmux new-session -d -c $start_dir -s "$type" \; \
75 $m -t "$type" \; \
76 new-window -c $start_dir
77 elif [ -d "$HOME/workdir/$type" ]; then
78 tmux new-session -d -c "$HOME/workdir/$type" -s "$type" \; \
79 $m -t "$type" \; \
80 send-keys "../start" C-m \; \
81 rename-window "running" \; \
82 new-window -c "$HOME/workdir/$type"
83 else
84 echo "Unknown session" >&2
85 false
86 fi
87 fi
88}
89
90_tmux_dev() {
91 COMPREPLY=()
92 local cur="${COMP_WORDS[COMP_CWORD]}"
93 prefix="$HOME/workdir/"
94 local IFS=$'\n'
95 local items=($(IFS=' ' compgen -W "bash remote puppet" -- $cur) $(compgen -d $prefix$cur))
96 for item in ${items[@]}; do
97 [[ $item == $prefix.* ]] && continue
98 COMPREPLY+=("${item#$prefix}")
99 done
100}
101complete -o filenames -F _tmux_dev tmux_dev
102
103if [ -n "$TMUX" ]; then 54if [ -n "$TMUX" ]; then
104 TMUX_SESSION_NAME=$(tmux display-message -p "#S") 55 TMUX_SESSION_NAME=$(tmux display-message -p "#S")
105 export HISTFILE="$XDG_STATE_HOME/bash/tmux_${TMUX_SESSION_NAME}_history" 56 export HISTFILE="$XDG_STATE_HOME/bash/tmux_${TMUX_SESSION_NAME}_history"