summaryrefslogtreecommitdiff
path: root/bashrc
blob: 8dd61380b07c550183483e74255d0ba20e3cd028 (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

# 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/exa ] && alias ls='exa'
[ -x /usr/bin/batcat ] && alias cat='batcat'

case "$TERM" in
	xterm*|rxvt*)
		TITLE='\[\e]0;\u@\h: \w\a\]'
		;;
	*)
		;;
esac

# prompt
reset='\[\033[0m\]'
yellow_b='\[\033[1;33m\]'
green='\[\033[0;32m\]'
red='\[\033[0;31m\]'
red_b='\[\033[1;31m\]'
[ $(id -u) -eq 0 ] && user_color=$red_b || user_color=$yellow_b
nrjobs='$([ \j -gt 0 ] && echo " [\j]")'
gitps='$(type -t __git_ps1 &>/dev/null && __git_ps1)'
[ -n "$debian_chroot" ] && chroot="[$debian_chroot] "
[ -n "$container" ] && container="[$container] "
PS1=${TITLE}"($user_color\u$reset@$green\h$reset) $container$chroot\W$gitps$nrjobs $red\\\$$reset > "

# 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 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="/bin/sh -c \"col -b -x | view -u ~/.vim/pager.vim -c 'set ft=man nomod nolist' -\""
export PERLDOC_PAGER=$MANPAGER


# 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