blob: a87858f8c4b1f3cf39dd57a05f5eb34be64d50fd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
# if not running interactively, don't do anything
[ -z "$PS1" ] && return
# include files
[ -f ~/.bash_aliases ] && source ~/.bash_aliases
[ -f /etc/bash_completion ] && source /etc/bash_completion
[ -e /usr/lib/git-core/git-sh-prompt ] && source /usr/lib/git-core/git-sh-prompt
[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"
[ -f ~/.cargo/env ] && source ~/.cargo/env
# bash options
shopt -s histappend # append to history instead of overwriting
shopt -s checkwinsize # check/update window dimenstions
# enable vi mode
set -o vi
bind -m vi-insert 'Control-l: clear-screen'
if [ "`id -u`" -eq 0 ]; then
# some aliases to avoid making mistakes:
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
fi
# colors for ls and grep
eval "`dircolors -b`"
export LS_COLORS=$LS_COLORS'mh=44;37:' # old coloring of hardlinks
alias ls='ls --color=auto --quoting-style=literal'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias rgrep='rgrep --color=auto'
alias vimwiki="vim -c VimwikiIndex"
[ -x /usr/bin/eza ] && alias ls='eza --no-quotes --icons'
[ -x /usr/bin/batcat ] && alias cat='batcat'
case "$TERM" in
xterm*|rxvt*)
TITLE='\[\e]0;\u@\h: \w\a\]'
;;
*)
;;
esac
before_command() {
command_timer=${command_timer:-$(date +%s)}
}
trap 'before_command' DEBUG
# prompt
__prompt_command() {
local exit_code=$?
PS1="${TITLE}"
local reset='\[\033[0m\]'
local yellow_b='\[\033[1;33m\]'
local green='\[\033[0;32m\]'
local red='\[\033[0;31m\]'
local red_b='\[\033[1;31m\]'
# user name
[ $(id -u) -eq 0 ] && local user_color=$red_b || local user_color=$yellow_b
PS1+="($user_color\u$reset@$green\h$reset)"
# chroot / container
if [ -n "$container" ]; then
PS1+=" [$container]"
fi
if [ -n "$debian_chroot" ]; then
PS1+=" [$debian_chroot]"
fi
# directory base
PS1+=" \W"
# git
local gitps='$(type -t __git_ps1 &>/dev/null && __git_ps1)'
PS1+="$gitps"
# background jobs
if [ -n "$(jobs -p)" ]; then
PS1+=" [\j]"
fi
# exit code
if [ $exit_code -gt 0 ]; then
PS1+=" <$red_b$exit_code$reset>"
fi
# runtime
local command_runtime=$(($(date +%s) - $command_timer))
unset command_timer
if [ $command_runtime -gt 0 ]; then
PS1+=" (${command_runtime}s)"
fi
PS1+=" $red\\\$$reset > "
}
PROMPT_COMMAND=__prompt_command
# history
HISTCONTROL='ignoredups:erasedups'
HISTSIZE=9999
export PATH=~/Apps/bin:$PATH
export EDITOR="/usr/bin/vim"
export SSH_ASKPASS=/usr/lib/openssh/gnome-ssh-askpass
export SSH_ASKPASS_REQUIRE=prefer
export WINEPREFIX=$HOME/.wine/default
export LESS="-R -M --shift 10"
export EMAIL="reiner@reiner-h.de"
export GPG_TTY=$(tty)
export RIPGREP_CONFIG_PATH=${HOME}/.config/ripgreprc
# use vim as pager (VimTip 167)
export MANPAGER="vim -u ~/.vim/pager.vim +MANPAGER --not-a-term -"
export PERLDOC_PAGER=$MANPAGER
export GROFF_NO_SGR=1
# fzf
[ -f /usr/share/doc/fzf/examples/key-bindings.bash ] && source /usr/share/doc/fzf/examples/key-bindings.bash
[ -f /usr/share/doc/fzf/examples/completion.bash ] && source /usr/share/doc/fzf/examples/completion.bash
[ -x "$(command -v tree)" ] && export FZF_ALT_C_OPTS="--preview 'tree -C {} | head -100'"
if [ -x "$(command -v fd)" ]; then
export FZF_DEFAULT_COMMAND='fd --type f --color=never'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_COMMAND='fd --type d . --color=never'
fi
|