#!/usr/bin/env bash # Bash configuration export BASH_SILENCE_DEPRECATION_WARNING=1 # XDG Base Directory export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}" export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}" export WORKSPACE_DIR="${WORKSPACE_DIR:-$HOME/.workspace}" export WORKSPACE="${WORKSPACE_DIR}" # Homebrew (macOS) if [[ "$OSTYPE" == "darwin"* ]]; then if [ -f "/opt/homebrew/bin/brew" ]; then eval "$(/opt/homebrew/bin/brew shellenv)" elif [ -f "/usr/local/bin/brew" ]; then eval "$(/usr/local/bin/brew shellenv)" fi fi # Go if [ -d "/usr/local/go" ]; then export GOROOT="/usr/local/go" export GOPATH="${WORKSPACE_DIR}" export GOBIN="${WORKSPACE_DIR}/bin" export GO111MODULE=on export GOPRIVATE=github.com/jchenry/* export PATH=$PATH:$GOROOT/bin:$GOBIN fi # Plan 9 if [ -d "/usr/local/plan9" ]; then # acme visible clicks export visibleclicks=1 export PLAN9="/usr/local/plan9" export PATH="$PATH:$PLAN9/bin" fi # History settings shopt -s histappend export HISTSIZE=100000 export HISTFILESIZE=10000000 export HISTCONTROL=ignoreboth export PROMPT_COMMAND="history -a; history -n" export HISTIGNORE="ls:ll:cd:pwd:bg:fg:history" # Aliases alias ll='ls -lah' alias la='ls -A' alias l='ls -CF' # Modern replacements if command -v eza &> /dev/null; then alias ls='eza' alias ll='eza -la' alias lt='eza --tree' fi if command -v bat &> /dev/null; then alias cat='bat' fi # fd for Debian (named fd-find) if command -v fdfind &> /dev/null && ! command -v fd &> /dev/null; then alias fd='fdfind' fi # Git completions if [ -f /usr/share/bash-completion/completions/git ]; then . /usr/share/bash-completion/completions/git fi # Starship prompt if command -v starship &> /dev/null; then eval "$(starship init bash)" fi # Zoxide (smarter cd) if command -v zoxide &> /dev/null; then eval "$(zoxide init bash)" fi # fzf if command -v fzf &> /dev/null; then if [ -f ~/.fzf.bash ]; then source ~/.fzf.bash elif [ -f /usr/share/doc/fzf/examples/key-bindings.bash ]; then source /usr/share/doc/fzf/examples/key-bindings.bash fi fi #1password/op source /Users/jchenry/.config/op/plugins.sh # Bootstrap the service account token via desktop-app auth. The token itself # lives in the Private vault, which the service account cannot read, so an # inherited OP_SERVICE_ACCOUNT_TOKEN would shadow desktop auth and fail with # "Private isn't a vault". Clear it for the read (env -u) to force desktop auth, # and guard the result so a failure leaves the var unset rather than an error. if [[ $- == *i* ]]; then __op_ref="op://Private/i3mrini3hbksiu2y37ovkobovm/credential" if __op_token=$(env -u OP_SERVICE_ACCOUNT_TOKEN op --account my.1password.com read "$__op_ref" 2>/tmp/op-bootstrap.err); then export OP_SERVICE_ACCOUNT_TOKEN="$__op_token" else echo "warning: could not read OP_SERVICE_ACCOUNT_TOKEN: $(cat /tmp/op-bootstrap.err)" >&2 fi unset __op_ref __op_token fi