-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bashrc
195 lines (150 loc) · 5.41 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# ~/.bashrc: executed by bash(2) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
bind '"\eOA": history-previous-history'
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;; # interactive
*) return;; # do nothing
esac
# ---------------------------- environment variables ---------------------------
export TERM=xterm-256color
export EDITOR=vim
export VISUAL=vim
export SCRIPTS="$HOME/.local/bin"
export SNIPPETS="$HOME/.local/snippets"
export VIMCONFIG="$HOME/.vim"
export SRC="$HOME/src"
export GIT="$HOME/src/git"
export HRULEWIDTH=80
# ------------------------------------ pager -----------------------------------
# this is how we get colored man pages oooooh so fancy
# no one honestly knows what most of this does but it does make it pretty
# these variables are designed so that man will work with them
# this is super broken on my ubuntu machine - why? TODO SHANA FIX
if test -x /usr/bin/lesspipe; then
export LESSOPEN="| /usr/bin/lesspipe %s";
export LESSCLOSE="/usr/bin/lesspipe %s %s";
fi
export LESS_TERMCAP_mb="^[[35m" # magenta
export LESS_TERMCAP_md="^[[33m" # yellow
export LESS_TERMCAP_me=""
export LESS_TERMCAP_se=""
export LESS_TERMCAP_so="^[[34m" # blue
export LESS_TERMCAP_ue=""
export LESS_TERMCAP_us="^[[4m" # underline
# this is broken
# export MANPAGER="less -R --use-color -Dd+r -Du+b"
# ----------------------------------- dircolors ---------------------------------
if command -v dircolors &> /dev/null; then # check if our system has dircolors (which ones dont't??)
if test -r ~/.config/ls/dircolors; then
eval "$(dircolors -b ~/.config/ls/dircolors)" # support custom dircolors
else
eval "$(dircolors -b)"
fi
fi
# we also want colored grep output
alias ls='ls -h --color=auto' # -h for human-readable output
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
# ------------------------------ bash shell options -----------------------------
shopt -s globstar
set -o noclobber
# because its bae
set -o vi
# keep history between sessions
shopt -s histappend
export HISTCONTROL=ignoreboth
export HISTSIZE=5000
export HISTFILESIZE=10000
# ------------------------------ command history -----------------------------
# we don't need this, bc we just search with / on vim mode
# bind '"\e[A": history-search-backward'
# bind '"\eOA": history-search-backward'
# bind '"\e[B": history-search-forward'
# bind '"\eOB": history-search-forward'
# ------------------------------------ prompt ------------------------------------
__ps1() {
# \u for user
# \W for short working directory
# date=$(date)
export PS1='\[\e[33m\]\u\[\e[30m\]@\[\e[34m\]\W\[\e[33m\]\$\[\e[0m\] '
# export PS1='\[\e[33m\]\u\[\e[30m\]@\[\e[34m\]\W\[\e[33m\]\$\[\e[0m\] '$(date)' '
}
PROMPT_COMMAND="__ps1"
# ------------------------------------ aliases -----------------------------------
# basic ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# my personal favies
alias more='less'
alias scripts='cd ${SCRIPTS}'
alias sz='source ~/.bashrc' # called sz for historical reasons (using zsh)
alias ez='vim ~/.bashrc' # same note
alias aliases='vim ~/.bashrc' # in zsh I had a separate aliases file
alias myip="curl http://ipecho.net/plain; echo"
alias c=clear
alias top=htop
alias shellcheck='function _sc(){ shellcheck -o all $1; }; _sc'
alias sc='function _sc(){ shellcheck -o all $1; }; _sc'
alias snippets='cd $SNIPPETS'
alias scripts='cd $SCRIPTS'
alias vip='vim -p'
# we're not using this file yet
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# ---------------------------------- functions -----------------------------------
cdtmp() {
name="$1"
mkdir -p "/tmp/$name"
cd "/tmp/$name"
}
# -------------------------------- tab completion -------------------------------
owncomp=(isosec)
for i in ${owncomp[@]}; do complete -C $i $i; done
# ------------------------------------ PATH -------------------------------------
pathappend() {
declare arg
for arg in "$@"; do
test -d "${arg}" || continue # if the directory doesn't exist, don't bother
if test "${arg}" = "." ; then
echo "Don't do that"
continue
fi
PATH=${PATH//:${arg}/} # if the directory is already in the path, remove it
PATH=${PATH#${arg}:} # if the directory is already in the path, first thing on the path, remove it
export PATH="${PATH:+"${PATH}:"}${arg}"
done
}
pathprepend() {
declare arg
for arg in "$@"; do
test -d "${arg}" || continue # if the directory doesn't exist, don't bother
if test "${arg}" = "." ; then
echo "Don't do that"
continue
fi
PATH=${PATH//:${arg}/} # if the directory is already in the path, remove it
PATH=${PATH#${arg}:} # if the directory is already in the path, first thing on the path, remove it
export PATH="${arg}:${PATH:+"${PATH}"}"
done
}
pathprepend "$SCRIPTS"
pathprepend "$SNIPPETS"
# export PATH="$SCRIPTS:$PATH"
# ----------------------------------- CDPATH ------------------------------------
# export CDPATH="$SCRIPTS:$CDPATH"
# export CDPATH=~/.local:"$CDPATH"
CDPATH=.:\
"$SCRIPTS":\
"$SNIPPETS":\
"$SRC":\
"$GIT":\
~/.local:\
# ------------------------------ configure utils -----------------------------
eval "$(thefuck --alias)"
# ----------------------------------- rust -----------------------------------
. "$HOME/.cargo/env"