|
# 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" |
|
|
|
# start ssh-agent |
|
eval $(ssh-agent > /dev/null 2>&1) |
|
|
|
# add all keys to ssh-agent |
|
ssh-add 2>/dev/null |
|
|
|
# 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 MISE_DATA_DIR="$HOME/.local/share/mise" |
|
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 OMNARA_BIN="$HOME/.omnara/bin" |
|
export OPENCODE_BIN="$HOME/.opencode/bin" |
|
export RUST_WITHOUT="rust-docs" |
|
export PATH="$MISE_DATA_DIR/shims:$HOME/.cargo/bin:$MODULAR_BIN:$HOME/.local/bin:$OPENCODE_BIN:$OMNARA_BIN:$BREW_PREFIX/bin:$BREW_PREFIX/sbin:$HOME/.pub-cache/bin:$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 "$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" |
|
|
|
# claude code |
|
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 |
|
|
|
# golang |
|
export GOPATH="${MISE_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="vim" |
|
|
|
# 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;}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" # TODO: switch to mise |
|
export UV_HTTP_TIMEOUT=60 |
|
export UV_PRERELEASE="allow" |
|
|
|
# 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' |
|
|
|
# Fallback colored prompt for when starship isn't available |
|
setup_fallback_prompt() { |
|
# Define colors |
|
local RESET='\[\033[0m\]' |
|
local BOLD='\[\033[1m\]' |
|
|
|
# 256-color palette for better compatibility |
|
local USER_COLOR='\[\033[38;5;76m\]' # bright green |
|
local HOST_COLOR='\[\033[38;5;76m\]' # bright green |
|
local PATH_COLOR='\[\033[38;5;214m\]' # orange |
|
local GIT_COLOR='\[\033[38;5;205m\]' # pink |
|
local PROMPT_COLOR='\[\033[38;5;15m\]' # white |
|
local ERROR_COLOR='\[\033[38;5;196m\]' # bright red |
|
|
|
# Git branch helper function |
|
parse_git_branch() { |
|
local branch=$(git branch 2>/dev/null | grep '^*' | cut -c3-) |
|
if [ -n "$branch" ]; then |
|
local status=$(git status --porcelain 2>/dev/null) |
|
if [ -n "$status" ]; then |
|
echo " ($branch *)" # asterisk indicates dirty |
|
else |
|
echo " ($branch)" |
|
fi |
|
fi |
|
} |
|
|
|
# Build prompt with return code color coding |
|
local prompt_symbol='λ' |
|
PS1="${USER_COLOR}${BOLD}\u${RESET}" # user |
|
PS1+="${USER_COLOR}@${RESET}" # @ |
|
PS1+="${HOST_COLOR}${BOLD}\h${RESET}" # host |
|
PS1+="${PROMPT_COLOR}:${RESET}" # : |
|
PS1+="${PATH_COLOR}\w${RESET}" # working directory |
|
PS1+="${GIT_COLOR}\$(parse_git_branch)${RESET}" # git branch |
|
PS1+="\n" # newline |
|
PS1+="${PROMPT_COLOR}${prompt_symbol}${RESET} " # prompt symbol |
|
} |
|
|
|
# Terminal color support check |
|
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then |
|
# Color is supported |
|
export TERM="${TERM:-xterm-256color}" |
|
|
|
# Set LS_COLORS for colorized ls output |
|
if command -v dircolors >/dev/null 2>&1; then |
|
eval "$(dircolors -b)" |
|
else |
|
# Fallback LS_COLORS if dircolors not available |
|
export LS_COLORS='di=1;34:ln=1;36:so=1;35:pi=1;33:ex=1;32:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43' |
|
fi |
|
|
|
# Colorize grep output |
|
export GREP_OPTIONS='--color=auto' |
|
export GREP_COLOR='1;32' |
|
|
|
# Update aliases for Linux |
|
if [[ $(uname) != "Darwin" ]]; then |
|
alias ls='ls --color=auto' |
|
alias grep='grep --color=auto' |
|
alias fgrep='fgrep --color=auto' |
|
alias egrep='egrep --color=auto' |
|
fi |
|
fi |
|
|
|
# starship or fallback |
|
if check_bin colorscript; then |
|
colorscript -e random |
|
fi |
|
|
|
if check_bin starship; then |
|
eval "$(starship init bash)" |
|
else |
|
setup_fallback_prompt |
|
fi |
|
|
|
# k8s |
|
export KUBECONFIG="$HOME/.kube/config" |
|
# TODO: fix _get_comp_words_by_ref |
|
# 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 |
Uh oh!
There was an error while loading. Please reload this page.