-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bashrc
281 lines (187 loc) · 5.85 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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
# vim:foldmethod=marker
# shellcheck shell=bash
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
BashrcStartTime=$(date +%s.%N)
BashrcNumErrors=0
# Error handling {{{
brcerrorhdlr() {
echo " ! Shell Init error on line $1"
((BashrcNumErrors++))
}
trap 'brcerrorhdlr $LINENO' ERR
# }}}
# Ctrl-C prevention {{{
trap 'echo "Nuh-uh!"' SIGINT
# }}}
clear
initmsg() {
echo -ne "\033[0;36m$1 "
}
# Basic init {{{
initmsg "sh"
stty -echo
set +o histexpand
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# TODO is this really the place to put this?
\mkdir -p "$HOME/.config/bash-configs"
# }}}
# Environment {{{
initmsg "env"
export EDITOR=/bin/vim
export PATH="$PATH:$HOME/.local/bin:$HOME/.cargo/bin:$HOME/configs/bin:/usr/local/go/bin:$HOME/bin:$HOME/.local/share/dotnet/.dotnet/tools"
export DOTNET_CLI_TELEMETRY_OPTOUT="true" # don't want no microsoft spying on me
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_STATE_HOME="$HOME/.local/state"
export XDG_CACHE_HOME="$HOME/.cache"
export NUGET_PACKAGES="$XDG_CACHE_HOME"/NuGetPackages
export NODE_REPL_HISTORY="$XDG_DATA_HOME"/node_repl_history
export ICEAUTHORITY="$XDG_CACHE_HOME"/ICEauthority
export GOPATH="$XDG_DATA_HOME"/go
export DOTNET_CLI_HOME="$XDG_DATA_HOME"/dotnet
export CARGO_HOME="$XDG_DATA_HOME"/cargo
export HISTFILE="${XDG_STATE_HOME}"/bash/history
export ANDROID_USER_HOME="$XDG_DATA_HOME"/android
mkdir -p "$XDG_STATE_HOME"/bash
# }}}
# Aliases and functions {{{
initmsg "fun" # kotlin moment
. ~/configs/.bash_functions
initmsg "alias"
. ~/configs/.bash_aliases
# BA and BF have their own error handler, this changes it
# to the BashRC one
trap 'brcerrorhdlr $LINENO' ERR
# }}}
# Programmable completion {{{
initmsg "comp"
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
# ^^^^ not guaranteed as this brc is meant to be portable across distros
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
# }}}
# WSL {{{
[ -f imrunningonwsl ] && {
initmsg "wsl"
WslDisplay=$(grep nameserver /etc/resolv.conf | awk '{print $2}')
export DISPLAY="${WslDisplay}:0.0"
}
# }}}
# Prompt customization {{{
initmsg "ps1"
# prompt customizatoin
PROMPT_DIRTRIM=3
PS1='$(ps1cs)\[\e[0;34m\]\@\[\e[0m\] $(git rev-parse --is-inside-work-tree > /dev/null 2>&1 && ps1gitinfo )\[\e[0;35m\]\u\[\e[0m\]@\[\e[0;35m\]\h \[\e[1;32m\]\w \[\e[0m\]$(randomcurrency) '
PS2="ok and? "
# ^^^
# dir trim: only last 3 folders displayed
# ps1: [uh or ok depending on whether command success] [time] [if in git repo then git stuff] [user]@[hostname] [cwd] [random currency]
# }}}
# Custom path {{{
if [ -f ~/.custompath ]; then
initmsg "cp"
# TODO function for reloading custom path at will
. ~/.custompath
export PATH="$PATH:$CUSTOMPATH"
fi
# }}}
export HTDOCS=/opt/lampp/htdocs
# devkitPro {{{
initmsg "dkp"
export DEVKITPRO=/opt/devkitpro
export DEVKITARM=${DEVKITPRO}/devkitARM
export DEVKITPPC=${DEVKITPRO}/devkitPPC
# }}}
# Intel compiler {{{
if [ -f "$HOME/intel/oneapi/setvars.sh" ]; then
initmsg "intel"
source "$HOME"/intel/oneapi/setvars.sh
fi
# }}}
# pfetch configuration {{{
initmsg "pfetch"
# do some pfetch configurationing
export PF_INFO="ascii title os host kernel uptime pkgs memory editor wm de shell palette"
# }}}
# pnpm {{{
initmsg "pnpm"
export PNPM_HOME="$HOME/.local/share/pnpm"
case ":$PATH:" in
*":$PNPM_HOME:"*) ;;
*) export PATH="$PNPM_HOME:$PATH" ;;
esac
# }}}
# Perl {{{
initmsg "perl"
PATH="$HOME/perl5/bin${PATH:+:${PATH}}"; export PATH;
PERL5LIB="$HOME/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB;
PERL_LOCAL_LIB_ROOT="$HOME/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT;
PERL_MB_OPT="--install_base \"$HOME/perl5\""; export PERL_MB_OPT;
PERL_MM_OPT="INSTALL_BASE=$HOME/perl5"; export PERL_MM_OPT;
# }}}
# Shell options {{{
initmsg "shopt"
shopt -s cdspell # Spell-checker for the `cd' command
shopt -s histappend # Append to history file instead of overwriting it
shopt -s checkwinsize # Check the window size (idk what this does)
# }}}
# Inconveniences {{{
initmsg "inc"
PROMPT_COMMAND="inconveniences; $PROMPT_COMMAND"
# }}}
# Check if python is installed {{{
initmsg "pychk"
if ! command -v python3 > /dev/null 2>&1; then
clear
echo "!!!! ATTENTION !!!!"
echo "YOU DO NOT HAVE PYTHON 3 INSTALLED !!!!!!!"
echo "INSTALL NOW OR YOU WILL REGRET IT!!!!!!!!!!!!!"
read -p -e "press enter"
clear
fi
# }}}
# *fetch {{{
# Run somethingfetch everytime the shell is started
BashrcFetchOk="1"
echo # absolutely required
"$HOME"/configs/ultra_fetcher_9000.py || BashrcFetchOk="0"
# }}}
# MSSC {{{
# Run Machine-Specific Startup Commands (MSSC)
# This became necessary when I wanted to install nvm on WSL but I don't use nvm on my laptop
stty echo
if [ -f "$HOME/.mssc" ]; then
echo -e "\n\033[0m"
source "$HOME"/.mssc
fi
stty -echo
# }}}
# Post-init stuff {{{
bashrc-postinit "$BashrcFetchOk"
trap - ERR
trap SIGINT
# }}}
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"
. "/home/moltony/.local/share/cargo/env"