]>
Commit | Line | Data |
---|---|---|
397c4fed IB |
1 | # |
2 | # ~/.bashrc | |
3 | # | |
4 | ||
a19180df | 5 | [[ -f "$XDG_STATE_HOME/bash/bashrc_temp" ]] && . $XDG_STATE_HOME/bash/bashrc_temp |
c235f9be | 6 | |
397c4fed IB |
7 | if [ -n "$HOME/.local/bin" ]; then |
8 | PATH="$HOME/.local/bin:$PATH" | |
9 | fi | |
10 | ||
11 | # If not running interactively, don't do anything | |
12 | [[ $- != *i* ]] && return | |
13 | ||
14 | export GPG_TTY=$(tty) | |
15 | export HISTFILE="$XDG_STATE_HOME/bash/history" | |
dd308b2f IB |
16 | export HISTTIMEFORMAT='%F %T ' |
17 | export HISTCONTROL="ignorespace:ignoredups" | |
397c4fed IB |
18 | |
19 | alias vi=vim | |
20 | alias ls='ls --color=auto -F -T 0' | |
21 | alias tmux='tmux -f $XDG_CONFIG_HOME/tmux/tmux.conf' | |
22 | ||
23 | alias grep='grep --color=auto' | |
24 | alias fgrep='fgrep --color=auto' | |
25 | alias egrep='egrep --color=auto' | |
26 | ||
27 | alias sudo="sudo " | |
28 | alias mv="mv -i" | |
29 | alias cp="cp -i" | |
30 | alias rm="rm -i" | |
31 | alias psp="pstree -aUp $USER" | |
853c1445 | 32 | alias info='info -v active-link-style=yellow,bold -v link-style=yellow' |
397c4fed | 33 | |
ae3ee401 IB |
34 | [[ -f /usr/share/stgit/completion/stgit-completion.bash ]] && . /usr/share/stgit/completion/stgit-completion.bash |
35 | ||
9f528ac4 IB |
36 | if [[ -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 | |
40 | fi | |
41 | ||
397c4fed IB |
42 | {% if role.get(profile) == "fretlink" %} |
43 | ##### Some Fretlink aliases | |
9f528ac4 IB |
44 | alias vpn=fl_vpn |
45 | alias tmux_dev=fl_tmux_dev | |
46 | complete -o filenames -F _fl_tmux_dev tmux_dev | |
397c4fed IB |
47 | |
48 | function dev_prompt() { | |
49 | if [ -n "$FRETLINK_ENV" ]; then | |
50 | echo "{$FRETLINK_ENV} " | |
51 | fi | |
52 | } | |
de1c634c | 53 | |
bfe7d9cb IB |
54 | if [ -n "$TMUX" ]; then |
55 | TMUX_SESSION_NAME=$(tmux display-message -p "#S") | |
56 | export HISTFILE="$XDG_STATE_HOME/bash/tmux_${TMUX_SESSION_NAME}_history" | |
57 | fi | |
397c4fed IB |
58 | ##### /Fretlink |
59 | {% endif %} | |
60 | ||
61 | # Non-printable chars need to be wrapped by \[ ... \] otherwise bash | |
62 | # will wrongly count the size of the prompt and glitch when going | |
63 | # through history | |
64 | function git_prompt_color() { | |
65 | git diff --quiet 2>/dev/null && git diff --cached --quiet 2>/dev/null | |
66 | gitstatus=$? | |
67 | if [ "$gitstatus" -gt 0 ]; then | |
68 | av=$'\033[01;31m' | |
69 | else | |
70 | av=$'\033[01;34m' | |
71 | fi | |
72 | echo "$av" | |
73 | } | |
74 | ||
75 | function git_prompt() { | |
76 | gitinfo=$(git branch 2>/dev/null | grep "^*" | cut -c3-); | |
77 | git diff --quiet 2>/dev/null && git diff --cached --quiet 2>/dev/null | |
78 | gitstatus=$? | |
79 | gitlsfiles=$(git ls-files . 2>/dev/null | wc -l); | |
80 | if [ "$gitinfo" -a "$gitlsfiles" -gt 0 ]; then | |
81 | echo -e "($gitinfo) " | |
82 | fi | |
83 | } | |
853c1445 | 84 | {% set ps1_git = '\[$(git_prompt_color)\]$(git_prompt)' %} |
397c4fed IB |
85 | |
86 | function error_code() { | |
87 | ret=$? | |
88 | if [[ $ret != 0 ]]; then | |
89 | echo "$ret " | |
90 | fi | |
91 | } | |
92 | ||
93 | function running_jobs() { | |
94 | ret=$(jobs | wc -l) | |
95 | if [[ $ret != 0 ]]; then | |
96 | echo "[$ret] " | |
97 | fi | |
98 | } | |
853c1445 | 99 | {% set ps1_status = '\[\\033[01;31m\]$(error_code)\[\\033[00;00m\]$(running_jobs)' -%} |
397c4fed | 100 | |
853c1445 IB |
101 | {# Ensure new line before the prompt #} |
102 | {% set ps1_newline = '$(printf "%$((`tput cols`-1))s\\r")' -%} | |
103 | ||
104 | {% set ps1_other = '' %} | |
105 | {% if role.get(profile) == "fretlink" -%} | |
106 | {% set ps1_other = '\[\\033[01;32m\]$(dev_prompt)' %} | |
107 | {%- endif %} | |
108 | ||
109 | PS1='{{ ps1_newline }}{{ ps1_status }}{{ ps1_other }}{{ ps1_git }}\[\033[00;32m\]\u@\h\[\033[94m\] \w \$\[\033[00m\] ' | |
397c4fed | 110 | |
853c1445 | 111 | PROMPT_COMMAND="[[ -f $XDG_STATE_HOME/bash/bashrc_temp ]] && . $XDG_STATE_HOME/bash/bashrc_temp" |
a19180df | 112 | |
397c4fed IB |
113 | {% if "nodejs" in features.get(profile, []) %} |
114 | source /usr/share/nvm/init-nvm.sh | |
115 | {% endif %} |