-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bashrc
363 lines (314 loc) · 10.2 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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
# ~/.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
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
HISTTIMEFORMAT="%Y-%m-%d %T "
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set better for nerdfont and nvim
export TERM=st-256color
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color | *-256color) color_prompt=yes ;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm* | rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*) ;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
#alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
#alias grep='grep --color=auto'
#alias fgrep='fgrep --color=auto'
#alias egrep='egrep --color=auto'
fi
# colored GCC warnings and errors
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# set PATH so it includes cargo bin if it exists
if [ -d "$HOME/.cargo/bin" ]; then
PATH="$HOME/.cargo/bin:$PATH"
else
# chromebook to small for rust
alias eza='exa'
fi
# some more ls aliases
alias ls='eza'
alias ll='eza -alh --git'
alias top='htop'
alias la='eza -a'
alias tree='eza -al --tree --level=3'
alias cat='batcat'
alias h='history'
# easy cd
alias ..="cd .."
alias ...="cd ../../"
alias ....="cd ../../../"
# further alias
alias apt='sudo nala'
alias update="apt upgrade -y; apt clean" # apt update; not req
alias venv='python -m venv'
alias mv='mv -i'
alias rm='trash -v'
alias mkdir='mkdir -p'
alias ps='ps auxf'
alias ping='ping -c 10'
alias less='less -R'
alias cls='clear'
alias tmux='tmux attach || tmux'
alias dmenu='rofi -dmenu -normal-window'
e() {
# emacs with files and no gtk error stream
emacs "$@" 2>/dev/null &
}
v() {
# nvim via the st terminal (nerd font)
st nvim "$@" 2>/dev/null &
}
#alias pgadmin='pgadmin4&'
alias tor='sudo systemctl restart tor'
alias n='nano'
alias did='history|grep'
alias ok='test $? == 0'
# useful functions
s() { # do sudo, or sudo the last command if no argument given
if [[ $# == 0 ]]; then
sudo "$(history -p '!!')"
else
sudo "$@"
fi
}
extract() {
# might add *.blwz from PiPy phinka module some time
if [ $# -eq 0 ]; then
# display usage if no parameters given
echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz|.zlib|.cso|.zst|.lha>"
echo " extract <path/file_name_1.ext> [path/file_name_2.ext] [path/file_name_3.ext]"
fi
for n in "$@"; do
if [ ! -f "$n" ]; then
echo "'$n' - file doesn't exist"
return 1
fi
case "${n%,}" in
*.cbt | *.tar.bz2 | *.tar.gz | *.tar.xz | *.tbz2 | *.tgz | *.txz | *.tar)
tar zxvf "$n"
;;
*.lzma) unlzma ./"$n" ;;
*.bz2) bunzip2 ./"$n" ;;
*.cbr | *.rar) unrar x -ad ./"$n" ;;
*.gz) gunzip ./"$n" ;;
*.cbz | *.epub | *.zip) unzip ./"$n" ;;
*.z) uncompress ./"$n" ;;
*.7z | *.apk | *.arj | *.cab | *.cb7 | *.chm | *.deb | *.iso | *.lzh | *.msi | *.pkg | *.rpm | *.udf | *.wim | *.xar | *.vhd)
7z x ./"$n"
;;
*.xz) unxz ./"$n" ;;
*.exe) cabextract ./"$n" ;;
*.cpio) cpio -id <./"$n" ;;
*.cba | *.ace) unace x ./"$n" ;;
*.zpaq) zpaq x ./"$n" ;;
*.arc) arc e ./"$n" ;;
*.cso) ciso 0 ./"$n" ./"$n.iso" &&
extract "$n.iso" && \rm -f "$n" ;;
*.zlib) zlib-flate -uncompress <./"$n" >./"$n.tmp" &&
mv ./"$n.tmp" ./"${n%.*zlib}" && rm -f "$n" ;;
*.dmg)
hdiutil mount ./"$n" -mountpoint "./$n.mounted"
;;
*.tar.zst) tar -I zstd -xvf ./"$n" ;;
*.zst) zstd -d ./"$n" ;;
*.lha) lha x ./"$n" ;;
*)
echo "extract: '$n' - unknown archive method"
return 1
;;
esac
done
}
# a whiptail alias set
export WHIP="whiptail"
# whiptail tail
export TAIL="0 0 3>&2 2>&1 1>&3"
# launch a process singleton
single() {
# self and process?
if test "$(ps | grep $1 | wc -l)" != 2; then
"$@" >/dev/null 2>&1 &
fi
}
# Automatically activate Python venv if it exists
auto_activate_venv() {
if [ -e "./bin/activate" ]; then
source ./bin/activate
fi
}
# Override the 'cd' command to call our function
cd() {
builtin cd "$@" && auto_activate_venv
}
# If you use pushd/popd, you can override them too.
pushd() {
builtin pushd "$@" && auto_activate_venv
}
popd() {
builtin popd "$@" && auto_activate_venv
}
# quick almost shortcut
# root rofi
//() {
rofi -show combi -normal-window &
}
/() {
cd "$(awk '{print $2}' ~/.local/share/autojump/autojump.txt | rofi -dmenu -normal-window)" || return
}
# fast GPT 3.5
#export OPENAI_API_KEY=
# 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).
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
# Ctrl+S forward search to match Ctrl-R reverse search
# so turn off xon/xoff flow control
stty -ixon
export TZ="UTC"
# add commit push
gacp() {
date=$(date +"%A %Y-%m-%d %H:%M:%S")
message="${1:-$date}"
git add .
git commit -m "$message"
git push
}
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ]; then
PATH="$HOME/bin:$PATH"
fi
# set PATH so it includes pipx's bin if it exists
if [ -d "$HOME/.local/bin" ]; then
PATH="$HOME/.local/bin:$PATH"
fi
# Arm kit
#PATH="/usr/local/gcc-arm-none-eabi-8-2018-q4-major/bin:$PATH"
# color vars
export NONE='\e[0m'
export RED='\e[1;31m'
export GREEN='\e[1;32m'
export YELLOW='\e[1;33m'
export BLUE='\e[1;34m'
export MAGENTA='\e[1;35m'
export CYAN='\e[1;36m'
export WHITE='\e[1;37m'
#ensure escape processing
alias echo='echo -e'
# notes (denoise echo vs. remove action => grouping)
echo "# command and location history search\n\
$CYAN^R$NONE is reverse command search. $CYAN^S$NONE is forward command\
search (No XON/XOFF). Directory autojump ${GREEN}j$NONE (and ${GREEN}jc$NONE)\
are installed. First parameter for match. ${GREEN}tldr$NONE for command help.\
${GREEN}fuck$NONE command corrector. Also ${GREEN}s$NONE last command sudo.\
${GREEN}h$NONE is for command history, also ${GREEN}did$NONE $RED!$NONE\n"
echo "# useful knowledge and additions\n\
$CYAN^D$NONE is end of stream terminate process. $CYAN^Z$NONE is process \
stop and ${GREEN}fg$NONE (and ${GREEN}bg$NONE) job control numbers.\
${GREEN}ll$NONE and ${GREEN}la$NONE do modified ${GREEN}ls$NONE types.\
${GREEN}espeak-ng$NONE for robot voice.\
${GREEN}entr$NONE file watcher command execute.\
${GREEN}extract$NONE archive type detection and extract.\
${GREEN}dragon$NONE CLI drag and drop manager.\
${CYAN}Shft+^V$NONE is paste in console context.\n"
echo "# code and data management\n\
${GREEN}gacp$NONE for git add/commit/push with optional message.\
${GREEN}fzf$NONE for fuzzy find.\
${GREEN}rg$NONE for ripgrep file word finder. ${GREEN}trash$NONE for trash\
can management. ${GREEN}update$NONE does all the software updating in one\
command. ${GREEN}ncdu$NONE is a disk usage analyzer.\n"
echo "# $RED~/bin$NONE general user binaries."
ls ~/bin
echo
echo "# $RED~/.local/bin$NONE for ${GREEN}pipx$NONE. You may need to allow\
packages to use the global python context installed via ${GREEN}apt$NONE.\
$RED~/.local/pipx/venvs/*/pyvenv.cfg$NONE"
ls ~/.local/bin
echo
# vscode seems to have tmux restart issue
echo "# can use ${GREEN}tmux ${CYAN}^B s <left/right/up/down> c <new win> & <kill win> number <select win>$NONE"
echo "# ${GREEN}pgadmin4$NONE in venv on http://127.0.0.1:5050"
single pgadmin4
echo "# ${GREEN}tor$NONE on? socks4://127.0.0.1:9050"
echo "# ${GREEN}fluid$NONE FLTK GUI designer (C++ template tool)"
echo "# ${GREEN}glade$NONE Gtk GUI designer (XML template tool)"
echo "# ${GREEN}p$NONE process launcher (rofi tool)"
echo "# ${GREEN}k$NONE cd to commonly used (rofi tool)"
echo "# ${GREEN}v$NONE neovim in st session"
echo
if [ -d "$HOME/.cargo/bin" ]; then
echo "# $RED~/.cargo/bin$NONE for rust binaries."
ls ~/.cargo/bin
echo
fi
# continue by doing the reset of the .profile file
echo "# .profile for perhaps .NET"
# Install Ruby Gems to ~/gems (for jekyll.sh github.com docs)
export GEM_HOME="$HOME/gems"
export PATH="$HOME/gems/bin:$PATH"
# starship (arm build on google drive)
eval "$(starship init bash)"
# activate virtual env after all path stuff
# autojump
. /usr/share/autojump/autojump.sh
# last, may include venv $PATH mash of added afterj
coproc espeak-ng "What are you doing Dave? They're all dead Dave."