-
Notifications
You must be signed in to change notification settings - Fork 1
/
.bashrc
120 lines (102 loc) · 3.02 KB
/
.bashrc
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
#!/usr/bin/bash
# ^ shebang is for shellcheck
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth:erasedups
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=2000
HISTFILESIZE=4000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# set a fancy prompt (non-color, unless we know we "want" color)
color_prompt=yes;
if [ "$color_prompt" = yes ]; then
# select proper color (root / ssh / user)
if [ "$(id -u)" == "0" ]; then
user_host_color='\[\033[01;31m\]' # red
elif [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
user_host_color='\[\033[01;33m\]' # yellow
else
user_host_color='\[\033[01;32m\]' # green
fi
path_color='\[\033[01;34m\]' # blue
reset_color='\[\033[00m\]'
else
user_host_color=
path_color=
reset_color=
fi
PS1=$user_host_color'\u@\h'$reset_color':'$path_color'\w'$reset_color'\$ '
unset color_prompt force_color_prompt
unset user_host_color path_color reset_color
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
eval "$(dircolors -b)"
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# Enable FZF if necessary
if command -v fzf > /dev/null; then
if ! command -v fzf-share > /dev/null; then
function fzf-share() {
if [ -d /usr/share/fzf ]; then
echo /usr/share/fzf
elif [ -d /usr/share/doc/fzf/examples ]; then
echo /usr/share/doc/fzf/examples
fi
}
fi
FZF_FILES=(
# SEE: pacman -Qlq fzf | grep bash
"$(fzf-share)/completion.bash"
"$(fzf-share)/key-bindings.bash"
)
for f in "${FZF_FILES[@]}"; do
if [ -f "$f" ]; then
source "$f"
fi
done
# Fine tuning: use fd when possible
if command -v fd > /dev/null; then
export FZF_DEFAULT_COMMAND='fd --type f'
fi
fi
# favorite editor
export EDITOR=nvim
# Optional things if not root
if [ "$(id -u)" != "0" ]; then
# local bin
export PATH="$HOME/.local/bin:$PATH"
# Java
export JAVA_HOME=/usr/lib/jvm/default
# Rust
#export RUST_SRC_PATH="$(rustc --print sysroot)/lib/rustlib/src/rust/src/"
export PATH="$PATH:/usr/lib/rustup/bin"
export PATH="$PATH:$HOME/.cargo/bin"
# bcc tools
export PATH="/usr/share/bcc/tools:$PATH"
export PATH="/usr/share/bpftrace/tools:$PATH"
# lean4
export PATH="$PATH:$HOME/.elan/bin"
fi
# Work items (not to be sync'ed)
for f in "$HOME/.config/bashrc"/*; do
if [ -f "$f" ]; then
source "$f"
fi
done
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias sr='stack ghci'