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