]> git.immae.eu Git - perso/Immae/Config/Ansible.git/blame - roles/shell/bash/templates/bashrc.j2
Add some dconf configuration
[perso/Immae/Config/Ansible.git] / roles / shell / bash / templates / bashrc.j2
CommitLineData
397c4fed
IB
1#
2# ~/.bashrc
3#
4
c235f9be
IB
5[[ -f "$HOME/.bashrc_temp" ]] && . $HOME/.bashrc_temp
6
397c4fed
IB
7if [ -n "$HOME/.local/bin" ]; then
8 PATH="$HOME/.local/bin:$PATH"
9fi
10
11# If not running interactively, don't do anything
12[[ $- != *i* ]] && return
13
14export GPG_TTY=$(tty)
15export HISTFILE="$XDG_STATE_HOME/bash/history"
16
17alias vi=vim
18alias ls='ls --color=auto -F -T 0'
19alias tmux='tmux -f $XDG_CONFIG_HOME/tmux/tmux.conf'
20
21alias grep='grep --color=auto'
22alias fgrep='fgrep --color=auto'
23alias egrep='egrep --color=auto'
24
25alias sudo="sudo "
26alias mv="mv -i"
27alias cp="cp -i"
28alias rm="rm -i"
29alias psp="pstree -aUp $USER"
30alias dotdrop="dotdrop --cfg $XDG_CONFIG_HOME/dotdrop/config.yaml"
31
32{% if role.get(profile) == "fretlink" %}
33##### Some Fretlink aliases
34alias getDump='s3cmd -c <(pass show Travail/Fretlink/S3) get '
35
36function vpn() {
37 TMPFILE=$(mktemp /tmp/openvpn.XXXXXX)
38 pass show Travail/Fretlink/OpenVPN >> $TMPFILE
39 sudo openvpn $TMPFILE
40 rm -f $TMPFILE
41}
42
43function dev_prompt() {
44 if [ -n "$FRETLINK_ENV" ]; then
45 echo "{$FRETLINK_ENV} "
46 fi
47}
48##### /Fretlink
49{% endif %}
50
51# Non-printable chars need to be wrapped by \[ ... \] otherwise bash
52# will wrongly count the size of the prompt and glitch when going
53# through history
54function git_prompt_color() {
55 git diff --quiet 2>/dev/null && git diff --cached --quiet 2>/dev/null
56 gitstatus=$?
57 if [ "$gitstatus" -gt 0 ]; then
58 av=$'\033[01;31m'
59 else
60 av=$'\033[01;34m'
61 fi
62 echo "$av"
63}
64
65function git_prompt() {
66 gitinfo=$(git branch 2>/dev/null | grep "^*" | cut -c3-);
67 git diff --quiet 2>/dev/null && git diff --cached --quiet 2>/dev/null
68 gitstatus=$?
69 gitlsfiles=$(git ls-files . 2>/dev/null | wc -l);
70 if [ "$gitinfo" -a "$gitlsfiles" -gt 0 ]; then
71 echo -e "($gitinfo) "
72 fi
73}
74
75function error_code() {
76 ret=$?
77 if [[ $ret != 0 ]]; then
78 echo "$ret "
79 fi
80}
81
82function running_jobs() {
83 ret=$(jobs | wc -l)
84 if [[ $ret != 0 ]]; then
85 echo "[$ret] "
86 fi
87}
88
89{% if role.get(profile) == "fretlink" %}
90PS1='\[\033[01;31m\]$(error_code)\[\033[00;00m\]$(running_jobs)\[\033[01;32m\]$(dev_prompt)\[$(git_prompt_color)\]$(git_prompt)\[\033[00;32m\]\u@\h\[\033[94m\] \w \$\[\033[00m\] '
91{% else %}
92PS1='\[\033[01;31m\]$(error_code)\[\033[00;00m\]$(running_jobs)\[$(git_prompt_color)\]$(git_prompt)\[\033[00;32m\]\u@\h\[\033[94m\] \w \$\[\033[00m\] '
93{% endif %}
94
95{% if "nodejs" in features.get(profile, []) %}
96source /usr/share/nvm/init-nvm.sh
97{% endif %}