|
# Verify that shell is interactive |
|
if [[ $- != *i* ]]; then return; fi |
|
|
|
# shellcheck disable=all |
|
|
|
# # .bashrc profiling start |
|
# export BASH_XTRACEFD=5 |
|
# PS4=":${BASH_SOURCE[0]##*/}:$LINENO+"; set -x |
|
|
|
# arch |
|
[[ $(sysctl -n machdep.cpu.brand_string) =~ "Apple M" ]] && arch='arm64' || arch='i386' |
|
|
|
# homebrew |
|
[[ $arch = 'arm64' ]] && BREW_PREFIX="/opt/homebrew" || BREW_PREFIX="/usr/local/bin" |
|
export HOMEBREW_NO_INSTALL_CLEANUP=1 |
|
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 |
|
|
|
# make |
|
export MAKEFLAGS="--jobs $(sysctl -n hw.ncpu)" |
|
|
|
# bash location |
|
arm() { arch -arm64 /opt/homebrew/bin/bash; } |
|
intel() { arch -x86_64 /usr/local/bin/bash; } |
|
|
|
# PATH |
|
## BAK (macOS): export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" || source /etc/profile |
|
export ASDF_DIR="$HOME/.asdf" |
|
export BUN="$HOME/.bun/bin" |
|
export BUN_INSTALL="$HOME/.bun" |
|
export GEM_HOME="$HOME/gems" |
|
export KREW_ROOT="$HOME/.krew" |
|
export MODULAR_HOME="$HOME/.modular" |
|
export MOJO_PATH=$(${BREW_PREFIX}/bin/modular config mojo.path) |
|
export MOJO_BIN="$MOJO_PATH/bin" |
|
export N_PREFIX="$HOME/.n" |
|
export NPM_GLOBAL="$HOME/.npm-global/bin" |
|
export RUST_WITHOUT="rust-docs" |
|
export PATH="$RBENV_DIR/shims:$HOME/.cargo/bin:$ASDF_DIR/shims:$MOJO_BIN:$BUN:$BUN_INSTALL/bin:$HOME/.local/bin:$BREW_PREFIX/bin:$HOME/.rd/bin:$KREW_ROOT/bin:$GEM_HOME/bin:$N_PREFIX/bin:$BREW_PREFIX/bin:/usr/local/opt/gnu-getopt/bin:/usr/local/bin:/usr/local:/usr/local/sbin:$HOME/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH" |
|
export PATH=$(echo -n $PATH | awk -v RS=: -v ORS=: '!x[$0]++' | sed "s/\(.*\).\{1\}/\1/") |
|
|
|
# shell completions |
|
[[ -f "$ASDF_DIR/asdf.sh" ]] && . "$ASDF_DIR/asdf.sh" |
|
[[ -f "$HOME/.cargo/env" ]] && . "$HOME/.cargo/env" |
|
[[ -f "$HOME/.fzf.bash" ]] && . "$HOME/.fzf.bash" |
|
[[ -f "$HOME/.gitleaks.bash" ]] && . "$HOME/.gitleaks.bash" |
|
[[ -f "$HOME/.hugo.bash" ]] && . "$HOME/.hugo.bash" |
|
|
|
# golang |
|
# * cf. https://gist.github.com/felipemeamaral/7ef508e59a42c4fa0d0b74f219f726c1 |
|
export GOPATH="$ASDF_DIR/shims" |
|
export GOROOT="$(go env GOROOT)" |
|
export GOCACHE=$HOME/go/cache |
|
export GOPROXY="https://proxy.golang.org,direct" |
|
export PATH="$GOPATH/bin:$PATH" |
|
|
|
# rbenv aliases |
|
eval "$(rbenv init - bash)" |
|
|
|
# Vim Default Editor |
|
export EDITOR="lvim" |
|
|
|
# Tame ansible-lint |
|
export LC_ALL=en_US.UTF-8 |
|
export LANG=en_US.UTF-8 |
|
|
|
# GLOBAL BASH HISTORY |
|
# Avoid duplicates |
|
HISTCONTROL=ignoredups:erasedups |
|
# When the shell exits, append to the history file instead of overwriting it |
|
shopt -s histappend |
|
|
|
# After each command, append to the history file and reread it |
|
PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a; history -c; history -r" |
|
|
|
# Forward search in bash (step forward via ctrl-s) |
|
stty -ixon |
|
|
|
# Set default blocksize for ls, df, du |
|
export BLOCKSIZE=1k |
|
|
|
# python |
|
# macOS: verify brew symlinks via `brew link --overwrite python` |
|
export PYTHONSTARTUP="$HOME/.config/startup.py" |
|
pip_install() { python -m pip install --user $@; } |
|
pip_uninstall() { python -m pip uninstall -y $@; } |
|
eval "$(register-python-argcomplete pipx)" |
|
export PIPX_DEFAULT_PYTHON="$ASDF_DIR/shims/python" |
|
|
|
# thefuck |
|
eval "$(thefuck --alias)" |
|
alias f='fuck' |
|
export THEFUCK_RULES='sudo:no_command' |
|
export THEFUCK_REQUIRE_CONFIRMATION='false' |
|
|
|
# starship |
|
colorscript -e random # crunch, random |
|
eval "$(starship init bash)" |
|
|
|
# k8s |
|
alias k="kubectl" |
|
alias kc="kubectl config use-context" |
|
alias kns='kubectl config set-context --current --namespace' |
|
alias kgns="kubectl config view --minify --output 'jsonpath={..namespace}' | xargs printf '%s\n'" |
|
export KUBECONFIG="$HOME/.kube/config:$HOME/.kube/k3s.yml:$HOME/.kube/minikube.yml" |
|
source <(kubectl completion bash) # `kc local` if it complains about 'Remote kubernetes server unreachable' |
|
complete -o default -F __start_kubectl k |
|
alias mk="minikube" |
|
# eval $(minikube -p minikube docker-env) |
|
# source <(minikube completion bash) |
|
|
|
# bash completion |
|
# ! have to source after kubectl to avoid `_get_comp_words_by_ref` error |
|
[[ -r "/opt/homebrew/etc/profile.d/bash_completion.sh" ]] && . "/opt/homebrew/etc/profile.d/bash_completion.sh" |
|
|
|
# argo |
|
alias argo="argo -n argo" # set namespace to 'argo' |
|
|
|
# ALIAS |
|
if [[ -f "$HOME/.bash_aliases" ]]; then source "$HOME/.bash_aliases"; fi |
|
alias rsync='rsync -arvW --progress --stats --ignore-existing' # archive, recursive, verbose, whole-file |
|
alias vim='lvim' # lunarvim |
|
alias mkdir='mkdir -pv' # Preferred 'mkdir' implementation |
|
alias ll='ls -FGlAhp' # Preferred 'ls' implementation |
|
alias ..='cd ../' # Go back 1 directory level |
|
alias ...='cd ../../' # Go back 2 directory levels |
|
alias diff='diff -W $(( $(tput cols) - 2 ))' # Full Terminal Width in Side-by-Side Mode |
|
alias flushdns='sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder' # Flush DNS ofc |
|
alias ip="ipconfig getifaddr $(networksetup -listallhardwareports | awk '/Hardware Port: Wi-Fi/{getline; print $2}')" # Private IP address |
|
alias ex-ip='curl icanhazip.com' # Your public IP address |
|
alias open-ports='sudo lsof -i | grep LISTEN' # All listening connections |
|
alias show-blocked='sudo ipfw list' # All ipfw rules inc/ blocked IPs |
|
alias bat='bat --paging=never' # cat clone via go |
|
alias dd='gdd' |
|
alias lzd='lazydocker' # Docker TUI |
|
alias youtube-dl='yt-dlp' |
|
|
|
# man pager |
|
export MANPAGER="sh -c 'col -bx | bat -l man -p'" |
|
|
|
# FUNCTIONS |
|
cd() { builtin cd "$@"; ll; } # Always list directory contents upon 'cd' |
|
iface() { route get 0.0.0.0 2>/dev/null | awk '/interface: / {print $2}'; } # Network interface |
|
mkpasswd() { docker run -it --rm alpine mkpasswd -m sha-512 "$@"; } # Pull mkpasswd and hash password |
|
lg() |
|
{ |
|
export LAZYGIT_NEW_DIR_FILE=~/.lazygit/newdir |
|
|
|
lazygit "$@" |
|
|
|
if [ -f $LAZYGIT_NEW_DIR_FILE ]; then |
|
cd "$(cat $LAZYGIT_NEW_DIR_FILE)" |
|
rm -f $LAZYGIT_NEW_DIR_FILE > /dev/null |
|
fi |
|
} |
|
|
|
# aws |
|
export AWS_VAULT_PROMPT=terminal |
|
export AWS_DEFAULT_PROFILE="dev.use1" |
|
|
|
# silence zsh shenanigans on 10.15+ |
|
if [[ $(sw_vers -buildVersion) =~ "21G72" ]]; then |
|
export BASH_SILENCE_DEPRECATION_WARNING=1 |
|
fi |
|
|
|
# playwright (firewall prompt) |
|
alias sign-playwright="sudo codesign --force --deep \ |
|
--sign - $HOME/Library/Caches/ms-playwright/chromium-*/chrome-mac/Chromium.app" |
|
|
|
# terraform |
|
alias tf='AWS_PROFILE="" terraform' |
|
alias tfi='AWS_PROFILE="" terraform init -backend-config=./state.conf' |
|
alias tfa='AWS_PROFILE="" terraform apply' |
|
alias tfp='AWS_PROFILE="" terraform plan' |
|
alias tfpn='AWS_PROFILE="" terraform plan -refresh=false' |
|
|
|
# multipass |
|
alias m='multipass' |
|
|
|
# zoxide (`cd` killer) |
|
eval "$(zoxide init --cmd cd bash)" |
|
|
|
# # .bashrc profiling end |
|
# set +x |