|
# 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 |
|
|
|
if [[ $(uname) = "Darwin" ]]; then |
|
# 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 |
|
|
|
# bash location |
|
arm() { arch -arm64 /opt/homebrew/bin/bash; } |
|
intel() { arch -x86_64 /usr/local/bin/bash; } |
|
|
|
# rust aarch64 target |
|
[[ $arch = 'arm64' ]] && export RUSTFLAGS="-C link-arg=-fuse-ld=ld" |
|
|
|
# make |
|
export MAKEFLAGS="--jobs $(sysctl -n hw.ncpu)" |
|
|
|
# set imagemagick version |
|
export MAGICK_HOME="${BREW_PREFIX}/opt/imagemagick@6" |
|
|
|
# set libssh flags (brew install libssh) |
|
export CFLAGS="-I${BREW_PREFIX}/include" |
|
export LDFLAGS="-L${BREW_PREFIX}/lib" |
|
|
|
# aliases |
|
alias ip="ipconfig getifaddr $(networksetup -listallhardwareports | awk '/Hardware Port: Wi-Fi/{getline; print $2}')" |
|
alias tailscale="/Applications/Tailscale.app/Contents/MacOS/Tailscale" |
|
|
|
# functions |
|
# TODO: Delete after https://github.com/microsoft/vscode/issues/204085 is fixed |
|
code() { |
|
command /usr/local/bin/code "$@" 2>/dev/null |
|
} |
|
else |
|
# homebrew |
|
BREW_PREFIX="/home/linuxbrew/.linuxbrew/bin" |
|
|
|
# make |
|
export MAKEFLAGS="--jobs $(nproc)" |
|
|
|
# disable bracketed paste |
|
bind 'set enable-bracketed-paste off' |
|
|
|
# aliases |
|
alias open='xdg-open' |
|
alias pbcopy='xclip -selection clipboard' |
|
alias pbpaste='xclip -selection clipboard -o' |
|
|
|
# functions |
|
code() { |
|
command /usr/bin/code-insiders "$@" 2>/dev/null |
|
} |
|
fi |
|
|
|
# PATH |
|
## BAK (macOS): export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" || source /etc/profile |
|
export ASDF_DATA_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 MODULAR_BIN="$MODULAR_HOME/bin" |
|
export N_PREFIX="$HOME/.n" |
|
export NPM_GLOBAL="$HOME/.npm-global/bin" |
|
export RUST_WITHOUT="rust-docs" |
|
export PATH="$ASDF_DATA_DIR/shims:$HOME/.cargo/bin:$MODULAR_BIN:$BUN:$BUN_INSTALL/bin:$HOME/.local/bin:$BREW_PREFIX/bin:$BREW_PREFIX/sbin:$HOME/.rd/bin:$KREW_ROOT/bin:$GEM_HOME/bin:$N_PREFIX/bin:$NPM_GLOBAL:/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_DATA_DIR/asdf.sh" ]] && . "$ASDF_DATA_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" |
|
[[ -f "$HOME/.kind-completion" ]] && . "$HOME/.kind-completion" |
|
|
|
# Source shell aliases |
|
[[ -f "$HOME/.bash_aliases" ]] && . "$HOME/.bash_aliases" |
|
|
|
# golang |
|
export GOPATH="$ASDF_DATA_DIR/shims" |
|
export GOCACHE="$HOME/go/cache" |
|
export GOPROXY="https://proxy.golang.org,direct" |
|
|
|
# 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 "$@"; } |
|
check_bin register-python-argcomplete && eval "$(register-python-argcomplete pipx)" |
|
export PIPX_DEFAULT_PYTHON="$ASDF_DATA_DIR/shims/python" |
|
export UV_HTTP_TIMEOUT=60 |
|
|
|
# TODO: adds literal seconds to prompt startup time |
|
# magic (mojo/modular) |
|
# # check_bin magic && eval "$(magic completion --shell bash)" |
|
|
|
# biome |
|
check_bin biome && \ |
|
biome() { |
|
command biome format \ |
|
--use-editorconfig=true \ |
|
--config-path="$HOME/.config/biome.jsonc" \ |
|
--write "$@" |
|
} |
|
|
|
# docker |
|
# * used with `act` for GitHub Actions |
|
# export DOCKER_HOST=$(docker context inspect --format '{{.Endpoints.docker.Host}}') |
|
|
|
# aliases (not in ~/.bash_aliases) |
|
alias ex-ip='curl icanhazip.com' |
|
alias youtube-dl='yt-dlp' |
|
|
|
# playwright (firewall prompt) |
|
sign_playwright() { |
|
sudo codesign --force --deep --sign - "$HOME/Library/Caches/ms-playwright/chromium-*/chrome-mac/Chromium.app" |
|
} |
|
|
|
# thefuck |
|
check_bin thefuck && eval "$(thefuck --alias)" |
|
alias f='fuck' |
|
export THEFUCK_RULES='sudo:no_command' |
|
export THEFUCK_REQUIRE_CONFIRMATION='false' |
|
|
|
# starship |
|
check_bin colorscript && colorscript -e random # crunch, random |
|
check_bin starship && eval "$(starship init bash)" |
|
|
|
# k8s |
|
export KUBECONFIG="$HOME/.kube/config:$HOME/.kube/k3s.yml:$HOME/.kube/minikube.yml" |
|
if check_bin kubectl; then |
|
source <(kubectl completion bash) |
|
complete -o default -F __start_kubectl k |
|
fi |
|
|
|
# man pager |
|
export MANPAGER="sh -c 'col -bx | bat -l man -p'" |
|
|
|
# aws |
|
export AWS_VAULT_PROMPT=terminal |
|
export AWS_DEFAULT_PROFILE="dev.use1" |
|
|
|
# silence zsh shenanigans on 10.15+ |
|
export BASH_SILENCE_DEPRECATION_WARNING=1 |
|
|
|
# zoxide (`cd` killer) |
|
check_bin zoxide && eval "$(zoxide init --cmd cd bash)" |
|
|
|
if [[ "$TERM_PROGRAM" == "ghostty" ]]; then |
|
export TERM=xterm-256color |
|
fi |
|
|
|
# .bashrc profiling end |
|
# set +x |