-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bashrc
238 lines (195 loc) · 7.27 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
# Amazon Q pre block. Keep at the top of this file.
[[ -f "${HOME}/Library/Application Support/amazon-q/shell/bashrc.pre.bash" ]] && builtin source "${HOME}/Library/Application Support/amazon-q/shell/bashrc.pre.bash"
#
# ~/.bashrc
# Made by Mykola Avramuk.
# Inspired by Mischa van den Burg, rwxrob, bahamas, and others.
# Thanks everyone and keep sharing your knowlege and best practices.
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
set -o vi
# Initialize Starship prompt
eval "$(starship init bash)"
# clear screen with Ctrl-l
bind -x '"\C-l":clear'
# ~~~~~~~~~~~~~~~ Environment Variables ~~~~~~~~~~~~~~~~~~~~~~~~
# Editor
export EDITOR="nvim"
# Directories
export REPOS="$HOME/Repos"
export GITUSER="avramukk"
export GHREPOS="$REPOS/github.com/$GITUSER"
export XDG_CONFIG_HOME="$HOME/.config"
export DOTFILES="$REPOS/dotfiles"
export SCRIPTS="$DOTFILES/scripts"
export LAB="$REPOS/lab"
export KUBE_EDITOR="nvim"
export SECOND_BRAIN="$HOME/Documents/second-brain"
# PATH
export GOBIN="$HOME/go/bin"
export GOPATH="$HOME/go"
export PATH="$PATH:$GOPATH/bin"
export PATH="$HOME/.cargo/bin:$PATH"
export PATH="$DOTFILES/scripts:$PATH"
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
# bun
export BUN_INSTALL="$HOME/.bun"
export PATH=$BUN_INSTALL/bin:$PATH
# OpenAI API Key
declare OPENAI_API_KEY
OPENAI_API_KEY="$(head -1 "$XDG_CONFIG_HOME/gpt/token")"
export OPENAI_API_KEY
# ~~~~~~~~~~~~~~~ History ~~~~~~~~~~~~~~~~~~~~~~~~
export HISTFILE=~/.histfile
export HISTSIZE=100000
export SAVEHIST=100000
export HISTCONTROL=ignorespace:ignoredups
PROMPT_COMMAND="history -a;$PROMPT_COMMAND"
# ~~~~~~~~~~~~~~~~Shell Options ~~~~~~~~~~~~~~~~~~
shopt -s cdspell # Correct minor spelling errors in cd
shopt -s checkwinsize # Check the window size after each command and, if necessary, update the values of LINES and COLUMNS.
shopt -s extglob # Extended globbing
shopt -s histappend # Append to the history file, don't overwrite it
# shopt -s cmdhist # Save multi-line commands as one command
# ~~~~~~~~~~~~~~~ Aliases ~~~~~~~~~~~~~~~~~~~~~~~~
# Quick navigation aliases
alias v=nvim
alias ..="cd .."
alias ...='cd ../..'
alias scripts='cd $SCRIPTS'
alias lab='cd $LAB'
alias dot='cd $REPOS/dotfiles'
alias repos='cd $REPOS'
alias c="clear"
alias cv='cd $REPOS/avramukk.github.io/'
alias sb='cd -P "$SECOND_BRAIN"'
alias fn='sb && nvim'
alias m='cd $REPOS/mischa'
alias md='cd $REPOS/mischa/dotfiles'
alias rd='cd $REPOS/rwxrob/dot'
alias chmox='chmod +x'
# ls with color and formatting
alias ls='ls --color=auto'
alias l='ls -l'
alias ll='ls -la'
alias la='ls -lathr'
# Find recent files
alias last='find . -type f -not -path "*/\.*" -exec ls -lrt {} +'
# Miscellaneous
alias t='tmux'
alias ta='tmux attach'
alias e='exit'
alias yt='yt-dlp'
alias pw='npx playwright'
alias gp='git pull'
alias gs='git status'
alias lg='lazygit'
alias ld='lazydocker'
alias ebr='v ~/.bashrc'
alias ea='v ~/.config/alacritty/alacritty.toml'
alias ek='v ~/.config/kitty/kitty.conf'
alias et='v ~/.tmux.conf'
alias ev='cd ~/.config/nvim/ && v init.lua'
alias sbr='source ~/.bashrc'
alias es='v ~/.config/starship.toml'
alias esk='v ~/.config/skhd/skhdrc'
alias eae='v ~/.config/aerospace/aerospace.toml'
alias tf='terraform'
alias tp='terraform plan'
alias python='python3'
alias k=kubectl
alias kubectl=kubecolor
source <(kubectl completion bash)
complete -o default -F __start_kubectl kubecolor
# complete -o default -F __start_kubectl k
alias kgp='kubectl get pods'
alias kgpo='kubectl get pods -o wide'
alias kc='kubectx'
alias kn='kubens'
alias ??='$DOTFILES/scripts/gpt'
alias nn='$DOTFILES/scripts/note'
alias icat="kitten icat"
# AWS profile aliases
alias mixa='export AWS_PROFILE=mixa && starship toggle aws'
alias slgfx='export AWS_PROFILE=slgfx && starship toggle aws'
alias mixa-e='export AWS_PROFILE=mixa-e && starship toggle aws'
alias vvcr-dev='export AWS_PROFILE=vvcr-dev-apps && starship toggle aws'
alias vvcr-stage='export AWS_PROFILE=vvcr-stage-apps && starship toggle aws'
alias vvcr-prod='export AWS_PROFILE=vvcr-prod-apps && starship toggle aws'
alias vvcr-dev-streamers='export AWS_PROFILE=vvcr-dev-streamers && starship toggle aws'
alias vvcr-stage-streamers='export AWS_PROFILE=vvcr-stage-streamers && starship toggle aws'
alias vvcr-prod-streamers='export AWS_PROFILE=vvcr-prod-streamers && starship toggle aws'
alias kolia='export AWS_PROFILE=kolia && starship toggle aws'
# gcloud alias
alias g='gcloud'
# Log aliases
alias logs-stage='aws logs tail /aws/elasticbeanstalk/vvcr-front-api-staging/var/log/web.stdout.log --follow --profile vvcr-stage-apps'
alias logs-dev='aws logs tail /aws/elasticbeanstalk/vvcr-front-api-dev/var/log/web.stdout.log --follow --profile vvcr-dev-apps'
alias logs-prod='aws logs tail /aws/elasticbeanstalk/vvcr-front-api-production/var/log/web.stdout.log --follow --profile vvcr-prod-apps'
# Streaming aliases
alias twitch='ffmpeg_loop ~/Movies/twitch.mp4'
alias timecode='ffmpeg_testsrc_live'
alias twitch60='ffmpeg_loop ~/Movies/twitch60.mp4'
# eks
# . <(eksctl completion bash)
# flux
# source <(flux completion bash)
# alias fgk='flux get kustomizations'
# talos
# source <(talosctl completion bash)
# EDB
# source <(kubectl-cnp completion bash)
# cilium
# source <(cilium completion bash)
# fzf aliases
alias ff="fzf --preview 'bat --style=numbers --color=always --line-range :501 {}'"
alias vf='v $(ff)'
# ~~~~~~~~~~~~~~~ Functions ~~~~~~~~~~~~~~~~~~~~~~~~
clone() {
local repo="$1"
local name="${repo##*/}"
name="${name%.git}"
local path="$HOME/Repos/$name"
if [[ -d "$path" ]]; then
cd "$path" || exit
echo "Already cloned $name"
return
fi
mkdir -p "$HOME/Repos"
cd "$HOME/Repos" || exit
echo gh repo clone "$repo" -- --recurse-submodule
gh repo clone "$repo" -- --recurse-submodule
cd "$name" || exit
}
export -f clone
sshf() {
local host="$(grep "^Host " ~/.ssh/config | awk '{print $2}' | fzf)"
ssh "$host"
}
export -f sshf
if [[ "$OSTYPE" == "darwin"* ]]; then
source "$HOME/.fzf.bash"
# echo "I'm on Mac!"
# brew bash completion
[[ -r "/opt/homebrew/etc/profile.d/bash_completion.sh" ]] && . "/opt/homebrew/etc/profile.d/bash_completion.sh"
else
# source /usr/share/fzf/key-bindings.bash
# source /usr/share/fzf/completion.bash
# The first one worked on Ubuntu, the eval one on Fedora. Keeping for reference.
# [ -f ~/.fzf.bash ] && source ~/.fzf.bash
eval "$(fzf --bash)"
fi
# ------------------------- NVM bulshit------------------------
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
### MANAGED BY RANCHER DESKTOP START (DO NOT EDIT)
export PATH="/Users/kolia/.rd/bin:$PATH"
### MANAGED BY RANCHER DESKTOP END (DO NOT EDIT)
# Amazon Q post block. Keep at the bottom of this file.
[[ -f "${HOME}/Library/Application Support/amazon-q/shell/bashrc.post.bash" ]] && builtin source "${HOME}/Library/Application Support/amazon-q/shell/bashrc.post.bash"
# The next line updates PATH for the Google Cloud SDK.
if [ -f '/Users/kolia/Downloads/google-cloud-sdk/path.bash.inc' ]; then . '/Users/kolia/Downloads/google-cloud-sdk/path.bash.inc'; fi
# The next line enables shell command completion for gcloud.
if [ -f '/Users/kolia/Downloads/google-cloud-sdk/completion.bash.inc' ]; then . '/Users/kolia/Downloads/google-cloud-sdk/completion.bash.inc'; fi