-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bashrc
132 lines (104 loc) · 3.32 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
121
122
123
124
125
126
127
128
129
130
131
132
# if not running interactively, don't do anything
if [ -z "$PS1" ]; then
return
fi
# source aliases
if [ -f "$HOME/.bash_aliases" ]; then
. "$HOME/.bash_aliases"
fi
# set cursor to blinking underline
echo -en "\033[3 q"
# ANSI escape sequences for colors
export COLOR_RESET='\e[0m'
export COLOR_BLACK='\e[0;30m'
export COLOR_GRAY='\e[1;30m'
export COLOR_RED='\e[0;31m'
export COLOR_LIGHT_RED='\e[1;31m'
export COLOR_GREEN='\e[0;32m'
export COLOR_LIGHT_GREEN='\e[1;32m'
export COLOR_BROWN='\e[0;33m'
export COLOR_YELLOW='\e[1;33m'
export COLOR_BLUE='\e[0;34m'
export COLOR_LIGHT_BLUE='\e[1;34m'
export COLOR_PURPLE='\e[0;35m'
export COLOR_LIGHT_PURPLE='\e[1;35m'
export COLOR_CYAN='\e[0;36m'
export COLOR_LIGHT_CYAN='\e[1;36m'
export COLOR_LIGHT_GRAY='\e[0;37m'
export COLOR_WHITE='\e[1;37m'
# display a colored exit code of last process
exit_code() {
local EXIT_CODE="$?"
if [ "$EXIT_CODE" = "0" ]; then
echo -en "$COLOR_LIGHT_GREEN"
else
echo -en "$COLOR_LIGHT_RED"
fi
echo -en "${EXIT_CODE}${COLOR_RESET}"
}
# escape ansi color escape sequence for use in PS1
_ps_color() {
if [ -z "$1" ]; then
echo "error: missing argument"
return 1
fi
echo "\[$1\]"
}
# update shell prompt
update_prompt() {
local PROMPT_COLOR
if [ -n "$SSH_CONNECTION" ]; then
PROMPT_COLOR=$(_ps_color "$COLOR_LIGHT_RED")
else
PROMPT_COLOR=$(_ps_color "$COLOR_LIGHT_GREEN")
fi
export PS1="\[\e[1m\]$PROMPT_COLOR\u@\h\[\e[0m\]:\[\e[1m\]\[\e[34m\]\w\[\e[0m\]\$ [\$(exit_code)] "
}
# colored man pages
LESS_TERMCAP_md=$(tput bold; tput setaf 4) # primary - blue, bold
LESS_TERMCAP_me=$(tput sgr0) # primary end - reset
LESS_TERMCAP_us=$(tput bold; tput setaf 2) # secondary - green, bold
LESS_TERMCAP_ue=$(tput sgr0) # secondary end - reset
LESS_TERMCAP_so=$(tput bold; tput setaf 1) # status line - red, bold
LESS_TERMCAP_se=$(tput rmso; tput sgr0) # status line end - reset
export LESS_TERMCAP_md LESS_TERMCAP_me LESS_TERMCAP_us LESS_TERMCAP_ue \
LESS_TERMCAP_so LESS_TERMCAP_se
# prepend to PATH
export PATH="$HOME/.local/bin:$PATH"
export PATH="$HOME/.scripts:$PATH"
# pnpm global store
export PATH="$HOME/.local/share/pnpm:$PATH"
# valgrind aliases
if command -v colour-valgrind &> /dev/null; then
alias valgrind='colour-valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all --track-origins=yes --show-reachable=yes --track-fds=yes -s'
alias stackusage='colour-valgrind --tool=drd --show-stack-usage=yes'
fi
# set default editor to neovim
export VISUAL="nvim"
export EDITOR="$VISUAL"
# don't save duplicates to history
export HISTCONTROL="ignoredups:ignorespace"
# disable ^S and ^Q
stty -ixon
# enable autocd - write dirname to cd into it
shopt -s autocd
# correct minor mistakes while using cd
shopt -s cdspell
# save multiline commands to history
shopt -s cmdhist
# append to the history file, don't overwrite it
shopt -s histappend
# check window size after each command and update LINES and COLUMNS
shopt -s checkwinsize
# disable core files
ulimit -c 0
# list jobs before logout (only on SSH)
if [ -n "$SSH_CONNECTION" ]; then
shopt -s checkjobs
fi
# enable programmable completion features
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
# set up shell prompt
update_prompt