-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.bashrc-personal
More file actions
executable file
·311 lines (260 loc) · 9.95 KB
/
.bashrc-personal
File metadata and controls
executable file
·311 lines (260 loc) · 9.95 KB
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
#!/bin/bash
# My personal .bashrc file complimentary to ArcoLinux .bashrc
# This file is sources by ArcoLinux .bashrc
export EDITOR='nvim'
export VISUAL='nvim'
export PAGER='bat'
#---History options---#
export HISTSIZE=1000000
export HISTFILESIZE=1000000
export HISTTIMEFORMAT='%F %T ' # don't put duplicate lines or lines starting with space in the history.
export HISTCONTROL=ignoreboth:erasedup # remove duplicates from historys
#export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND" # append to the history file immediately instead of saving on closing session
shopt -s histappend # append to the history file, don't overwrite it
## HSTR configuration
alias hh=hstr # hh to be alias for hstr
export HSTR_CONFIG=blacklist,prompt-bottom,raw-history-view,hicolor
export PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}"
function hstrnotiocsti {
{ READLINE_LINE="$( { </dev/tty hstr ${READLINE_LINE}; } 2>&1 1>&3 3>&- )"; } 3>&1;
READLINE_POINT=${#READLINE_LINE}
}
### if this is interactive shell, then bind hstr to Ctrl-r (for Vi mode check doc)
if [[ $- =~ .*i.* ]]; then bind -x '"\C-r": "hstrnotiocsti"'; fi
export HSTR_TIOCSTI=n
#---Thismachineonlyrc---#
[ -f ~/.thismachineonlyrc ] && source ~/.thismachineonlyrc
#---Terminal options---#
# check the window size after each command and, if necessary, update the values of LINES and COLUMNS.
shopt -s checkwinsize
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# colored GCC warnings and errors
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
#---System options---#
# ssh-agent
if ! pgrep -u "$USER" ssh-agent > /dev/null; then
ssh-agent -t 1h > "$XDG_RUNTIME_DIR/ssh-agent.env"
fi
if [[ ! "$SSH_AUTH_SOCK" ]]; then
source "$XDG_RUNTIME_DIR/ssh-agent.env" > /dev/null
fi
# FZF settings
# export FZF_DEFAULT_COMMAND='ag --hidden --ignore .git -g ""'
export FZF_DEFAULT_COMMAND='rg --hidden -l ""'
export FZF_CTRL_T_COMMAND='rg --hidden -l ""'
#---Aliases---#
# Unalias some commands
unalias cb
unalias cz
unalias cf
# Bare repo config
alias config='git --git-dir=$HOME/.dotfiles --work-tree=$HOME'
# Make ranger change current directory after quit
alias ranger='ranger --choosedir=$HOME/.rangerdir; LASTDIR=`cat $HOME/.rangerdir`; cd "$LASTDIR"'
# List
alias ls="exa -l"
# alias cat="bat"
# Add an "alert" alias for long running commands. Example usage: sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# Set pwd as PYTHONPATH
alias epp="export PYTHONPATH=`pwd`"
#pyclean - remove pyc files
pyclean () {
find . -type f -name "*.py[co]" -delete
find . -type d -name "__pycache__" -delete
}
# Toggle python virtualenv
v() {
if [[ -n "$VIRTUAL_ENV" ]]; then
if [[ -d "./venv" || -d "./.venv" ]]; then
deactivate
echo "Virtual environment deactivated."
elif [[ -f "poetry.lock" ]]; then
exit
else
echo "Don't know how to deactivate virtual environment."
fi
else
if [[ -d "./venv" ]]; then
source ./venv/bin/activate
echo "Virtual environment activated. Python version: `python --version | cut -d' ' -f2`"
elif [[ -d "./.venv" ]]; then
source ./.venv/bin/activate
echo "Virtual environment activated. Python version: `python --version | cut -d' ' -f2`"
elif [[ -f "poetry.lock" ]]; then
poetry shell
else
echo "Don't know how to activate virtual environment."
fi
fi
}
alias pybeautify="git status -s | grep '??' | cut -f2 -d' ' | xargs -I __ sh -c 'echo __ && isort __ && black -l 100 __'"
# Git aliases
alias gst='git status'
alias gaa='git add -A'
alias ga='git add -p'
alias gai='git add -i'
alias gcm='git commit'
alias gcma='git commit -a'
alias gcmapf='git commit --amend && git push -f'
alias gwait='git reset HEAD' # Unstages everything.
alias gl='git log --graph --pretty='\''%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'\'' --abbrev-commit --date=relative'
alias gundo='git reset --soft HEAD^' # Undoes the last commit and moves the files in the commit to staging.
alias gco='git checkout'
alias gpusho="git push origin ${parse_git_branch}"
alias gpullo="git pull --rebase origin ${parse_git_branch}"
alias gstart="git checkout main && git pull && git checkout -b "
nah () {
git reset --hard
git clean -df
if [ -d ".git/rebase-apply" ] || [ -d ".git/rebase-merge" ]; then
git rebase --abort
fi
}
# Useful git aliases
# 20 most often changing files, run from /src or /app
alias git_most_changing='git log --format=format: --name-only --since="1 year ago" | sort | uniq -c | sort -nr | head -20'
# All contributors, ranked by commit count
alias git_contributors='git shortlog -sn --no-merges'
# 20 most often changing, bug-related files
alias git_buggy_files='git log -i -E --grep="fix|bug|broken" --name-only --format='' | sort | uniq -c | sort -nr | head -20'
# Commit count by month
alias git_commit_count_by_month='git log --format='%ad' --date=format:'%Y-%m' | sort | uniq -c'
# Crisis commits
alias git_hotfix_frequency="git log --oneline --since='1 year ago' | grep -iE 'revert|hotfix|emergency|rollback'"
# Config management aliases
alias cst='config status'
alias ca='config add -p'
alias cai='config add -i'
alias ccm='config commit'
alias cwait='config reset HEAD' # Unstages everything.
alias cl='config log --graph --pretty='\''%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'\'' --abbrev-commit'
alias cundo='config reset --soft HEAD^' # Undoes the last commit and moves the files in the commit to staging.
alias cco='config checkout'
alias cpush="config push"
# docker aliases
alias dcu="docker compose up"
alias dcud="docker compose up -d"
alias dcd="docker compose down"
alias dps="docker ps"
# current song in hpr4
alias hpr4=hpr4-current-song | while read song; do notify-send "$song"; done
# test microphone
alias test-mic="arecord -d 5 test-mic.wav && sleep 1 && aplay test-mic.wav && rm test-mic.wav"
# kitty terminal oriented aliases
alias kdiff="kitty +kitten diff"
# copy to clipboard/primary/secondary
if [[ -z "$WAYLAND_DISPLAY" ]]; then
alias copy="xclip -selection clipboard"
alias copyp="xclip -selection primary"
alias copys="xclip -selection secondary"
else
alias copy="wl-copy"
alias copyp="wl-copy --primary"
alias copys="wl-copy --secondary"
fi
eval "$(starship init bash)"
#
# Installation:
#
# Via shell config file ~/.bashrc (or ~/.zshrc)
#
# Append the contents to config file
# 'source' the file in the config file
#
# You may also have a directory on your system that is configured
# for completion files, such as:
#
# /usr/local/etc/bash_completion.d/
###-begin-flutter-completion-###
if type complete &>/dev/null; then
__flutter_completion() {
local si="$IFS"
IFS=$'\n' COMPREPLY=($(COMP_CWORD="$COMP_CWORD" \
COMP_LINE="$COMP_LINE" \
COMP_POINT="$COMP_POINT" \
flutter completion -- "${COMP_WORDS[@]}" \
2>/dev/null)) || return $?
IFS="$si"
}
complete -F __flutter_completion flutter
elif type compdef &>/dev/null; then
__flutter_completion() {
si=$IFS
compadd -- $(COMP_CWORD=$((CURRENT-1)) \
COMP_LINE=$BUFFER \
COMP_POINT=0 \
flutter completion -- "${words[@]}" \
2>/dev/null)
IFS=$si
}
compdef __flutter_completion flutter
elif type compctl &>/dev/null; then
__flutter_completion() {
local cword line point words si
read -Ac words
read -cn cword
let cword-=1
read -l line
read -ln point
si="$IFS"
IFS=$'\n' reply=($(COMP_CWORD="$cword" \
COMP_LINE="$line" \
COMP_POINT="$point" \
flutter completion -- "${words[@]}" \
2>/dev/null)) || return $?
IFS="$si"
}
compctl -K __flutter_completion flutter
fi
###-end-flutter-completion-###
### yy shell wrapper for changing current directory when exitin yazi
function yy() {
local tmp="$(mktemp -t "yazi-cwd.XXXXXX")"
yazi "$@" --cwd-file="$tmp"
if cwd="$(cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
cd -- "$cwd"
fi
rm -f -- "$tmp"
}
### Maven
alias mvn21="JAVA_HOME=/usr/lib/jvm/java-21-openjdk/ mvn"
### Bitwarden
alias passgen="bw generate -luns --length 32 | copy"
### Search and replace with vim
vsed() {
search=$1
replace=$2
shift
shift
vim -c "bufdo! set eventignore-=Syntax| %s/$search/$replace/gce" $*
}
### PS with grep
alias pg="ps auxw | grep -v grep | grep $1"
# The next line updates PATH for the Google Cloud SDK.
if [ -f '/home/norbert/Dev/google-cloud-sdk/path.bash.inc' ]; then . '/home/norbert/Dev/google-cloud-sdk/path.bash.inc'; fi
# The next line enables shell command completion for gcloud.
if [ -f '/home/norbert/Dev/google-cloud-sdk/completion.bash.inc' ]; then . '/home/norbert/Dev/google-cloud-sdk/completion.bash.inc'; fi
fastfetch -c ~/.config/fastfetch/config.json
# Terraform autocomplete
complete -C /usr/bin/terraform terraform
# Packages utils
alias list-biggest-packages='expac "%n %m" -l"\n" -Q $(pacman -Qq) -H M | sort -rhk 2 | less'
# Claude profiles - smart switching based on directory
claude() {
if [[ "$PWD" == ~/Work/Tequipy/* ]]; then
CLAUDE_CONFIG_DIR=~/.claude/accounts/tequipy command claude "$@"
else
command claude "$@"
fi
}
# NVM setup
. /usr/share/nvm/init-nvm.sh
# Zoxide setup
alias cd='z'
eval "$(zoxide init bash)"
# Mise setup
eval "$(mise activate bash)"
# Tirith setup
# eval "$(tirith init)"