Skip to content

Commit

Permalink
resync everything, it's been a while
Browse files Browse the repository at this point in the history
  • Loading branch information
jzelinskie committed Sep 16, 2023
1 parent c24e676 commit b65643f
Show file tree
Hide file tree
Showing 9 changed files with 247 additions and 157 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
.DS_Store?
.Spotlight-V100
.Trashes
.helix
._*
.env
.git/**
.python-version
Brewfile.lock.json
Icon?
Thumbs.db
ehthumbs.db
id_ed25519
Expand Down
2 changes: 1 addition & 1 deletion .ripgreprc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--glob
!{.git}
!{.git,.next,node_modules}
--no-binary
--hidden
--no-ignore-vcs
234 changes: 128 additions & 106 deletions .zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,109 +6,116 @@ export XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share}
export XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}

# add ~/.local/bin to $PATH if it exists
[[ -d "$HOME/.local/bin" ]] && path=($HOME/.local/bin $path)
[[ -d ~/.local/bin ]] && path=(~/.local/bin $path)

# add brew to $PATH (prezto brew module needs it on the path)
[[ -d "/opt/homebrew" ]] && eval "$(/opt/homebrew/bin/brew shellenv)"
[[ -d "$HOME/.linuxbrew" ]] && eval "$($HOME/.linuxbrew/bin/brew shellenv)"
if which brew > /dev/null; then export DYLD_FALLBACK_LIBRARY_PATH=$(brew --prefix)/lib; fi
[[ -d /opt/homebrew ]] && eval "$(/opt/homebrew/bin/brew shellenv)"
[[ -d ~/.linuxbrew ]] && eval "$(~/.linuxbrew/bin/brew shellenv)"
if command -v brew > /dev/null; then export DYLD_FALLBACK_LIBRARY_PATH=$(brew --prefix)/lib; fi

# zgen
export ZGEN_DIR=$XDG_DATA_HOME/zgen
export ZGEN_RESET_ON_CHANGE=($HOME/.zshrc)
export ZGEN_PLUGIN_UPDATE_DAYS=30
export ZGEN_SYSTEM_UPDATE_DAYS=30
export ZGEN_DIR=$XDG_DATA_HOME/zgenom
export NVM_LAZY_LOAD=true
[[ ! -d $ZGEN_DIR ]] && git clone git@github.com:tarjoilija/zgen.git $ZGEN_DIR
source "$ZGEN_DIR/zgen.zsh"
if ! zgen saved; then
[[ ! -d $ZGEN_DIR ]] && git clone git@github.com:jandamm/zgenom.git "$ZGEN_DIR"
# shellcheck disable=SC1091
source "$ZGEN_DIR/zgenom.zsh"
zgenom autoupdate
if ! zgenom saved; then
zgenom compdef

# plugins
zgen load docker/cli contrib/completion/zsh
zgen load lukechilds/zsh-nvm
zgen load peterhurford/git-it-on.zsh
zgen load rupa/z
zgen load unixorn/autoupdate-zgen
zgen load zsh-users/zsh-completions src
zgen load zsh-users/zsh-history-substring-search
zgen load zsh-users/zsh-syntax-highlighting
[[ -d $HOME/.zfunc ]] && zgen load $HOME/.zfunc
which brew > /dev/null && zgen load $(brew --prefix)/share/zsh/site-functions
zgenom load docker/cli contrib/completion/zsh
zgenom load lukechilds/zsh-nvm
zgenom load peterhurford/git-it-on.zsh
zgenom load rupa/z
zgenom load unixorn/autoupdate-zgen
zgenom load zsh-users/zsh-completions src
zgenom load zsh-users/zsh-history-substring-search
zgenom load zsh-users/zsh-syntax-highlighting

# local config to compile
zgenom compile "$(brew --prefix)/share/zsh/site-functions"
zgenom compile ~/.zfunc
zgenom compile ~/.zshrc

# prezto config
zgen prezto
zgen prezto environment
zgen prezto terminal
zgen prezto editor
zgen prezto history
zgen prezto directory
zgen prezto helper
zgen prezto spectrum
zgen prezto homebrew
zgen prezto utility
zgen prezto prompt
zgen prezto syntax-highlighting
zgen prezto git
zgen prezto editor key-bindings 'emacs'
zgen prezto '*:*' case-sensitive 'no'
zgen prezto '*:*' color 'yes'
zgen prezto 'module:editor' dot-expansion 'yes'
zgen prezto 'module:editor' key-bindings 'emacs'
zgen prezto 'module:syntax-highlighting' highlighters 'main' 'brackets' 'pattern' 'cursor'
zgen prezto 'module:terminal' auto-title 'yes'
if [[ $OSTYPE == darwin* ]]; then zgen prezto prompt theme 'sorin'; else zgen prezto prompt theme 'skwp'; fi
zgen save
zgenom prezto
zgenom prezto environment
zgenom prezto terminal
zgenom prezto editor
zgenom prezto history
zgenom prezto directory
zgenom prezto helper
zgenom prezto spectrum
zgenom prezto homebrew
zgenom prezto utility
zgenom prezto prompt
zgenom prezto syntax-highlighting
zgenom prezto git
zgenom prezto editor key-bindings 'emacs'
zgenom prezto '*:*' case-sensitive 'no'
zgenom prezto '*:*' color 'yes'
zgenom prezto 'module:editor' dot-expansion 'yes'
zgenom prezto 'module:editor' key-bindings 'emacs'
zgenom prezto 'module:syntax-highlighting' highlighters 'main' 'brackets' 'pattern' 'cursor'
zgenom prezto 'module:terminal' auto-title 'yes'

if [[ $OSTYPE == darwin* ]]; then
zgenom prezto prompt theme 'sorin'
else
zgenom prezto prompt theme 'skwp'
fi

zgenom save
fi

# disable ctrl+d EOF
setopt ignoreeof

# prefer nvim as $EDITOR
if which hx > /dev/null; then
# Editor preferences: Helix > Neovim > Vim
if command -v hx > /dev/null; then
export EDITOR=hx
elif which nvim > /dev/null; then
elif command -v nvim > /dev/null; then
export EDITOR=nvim
alias vi=nvim
alias vim=nvim
alias -g vi=nvim
alias -g vim=nvim
else
export EDITOR=vim
alias nvim=vim
alias -g nvim=vim
fi
export GIT_EDITOR=$EDITOR
export VISUAL=$EDITOR

# less
export PAGER='less'
export LESS='-F -g -i -M -R -S -w -X -z-4'
if (( $+commands[lesspipe.sh] )); then
if (( ${+commands[lesspipe.sh]} )); then
export LESSOPEN='| /usr/bin/env lesspipe.sh %s 2>&-'
fi

# cross-platform clipboard
if which xclip > /dev/null; then
alias pbcopy='xclip -selection clipboard'
alias pbpaste='xclip -selection clipboard -o'
if command -v xclip > /dev/null; then
alias -g pbcopy='xclip -selection clipboard'
alias -g pbpaste='xclip -selection clipboard -o'
fi

# navigating text
# mac-style text navigation for minimal terminal emulators
bindkey "\e[1;3D" backward-word # ⌥←
bindkey "\e[1;3C" forward-word # ⌥→

# prefer exa and fix prezto aliases when using it
if which exa > /dev/null; then
alias ls='exa'
alias ll='exa --long --header --group --inode --blocks --links --modified --accessed --created --git'
alias la='ll -a'
alias tree='exa -T'
# lsd
if command -v lsd > /dev/null; then
alias -g ls='lsd'
alias -g tree='lsd --tree'
fi

# icat
if which kitty > /dev/null; then alias icat='kitty +kitten icat'; fi
if command -v kitty > /dev/null; then
alias -g icat='kitty +kitten icat'
fi

# global ripgrep config
if which rg > /dev/null; then export RIPGREP_CONFIG_PATH=$HOME/.ripgreprc; fi
if command -v rg > /dev/null; then export RIPGREP_CONFIG_PATH=~/.ripgreprc; fi

# add sandboxed tailscale to path
[[ -s /Applications/Tailscale.app/Contents/MacOS ]] && path=(/Applications/Tailscale.app/Contents/MacOS $path)
[[ -s /Applications/Tailscale.app/Contents/MacOS ]] && path=("/Applications/Tailscale.app/Contents/MacOS" $path)

# 1password 8 ssh-agent
[[ $OSTYPE == darwin* ]] && export SSH_AUTH_SOCK="$HOME/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock"
Expand All @@ -117,19 +124,22 @@ if which rg > /dev/null; then export RIPGREP_CONFIG_PATH=$HOME/.ripgreprc; fi
[[ $(uname -r) == *Microsoft ]] && export BROWSER=wsl-open

# create an alias to the first argument, if the second argument exists
function alias_if_exists() { which $2 > /dev/null && alias $1=$2; }
alias_if_exists "cat" "bat"
alias_if_exists "compose" "docker-compose"
alias_if_exists "k" "kubectl"
alias_if_exists "kctx" "kubectx"
alias_if_exists "mk" "minikube"
alias_if_exists "open" "xdg-open"
alias_if_exists "open" "wsl-open"
alias_if_exists "sed" "gsed"
alias_if_exists "jq" "faq"
function alias_if_exists() { which "$2" > /dev/null && alias -g "$1"="$2"; }
alias_if_exists cat bat
alias_if_exists compose docker-compose
alias_if_exists k kubectl
alias_if_exists kctx kubectx
alias_if_exists kns kubens
alias_if_exists g git
alias_if_exists mk minikube
alias_if_exists open xdg-open
alias_if_exists open wsl-open
alias_if_exists sed gsed
alias_if_exists jq faq
alias_if_exists cue ~/Downloads/cue_v0.4.2_darwin_arm64/cue

# source a script, if it exists
function source_if_exists() { [[ -s $1 ]] && source $1 }
function source_if_exists() { [[ -s $1 ]] && source "$1"; }
source_if_exists "$HOME/.gvm/scripts/gvm"
source_if_exists "$HOME/.iterm2_shell_integration.zsh"
source_if_exists "$HOME/.nix-profile/etc/profile.d/nix.sh"
Expand All @@ -140,85 +150,97 @@ if [[ -S "$HOME/.colima/docker.sock" ]]; then
fi

# Keep Go state in ~/.go and add the default GOBIN to the path
if which go > /dev/null; then
if command -v go > /dev/null; then
export GOPATH=${XDG_DATA_HOME:-$HOME/.local/share}/go
[[ -d $GOPATH/bin ]] && path=($GOPATH/bin $path)
if which brew > /dev/null; then export CGO_LDFLAGS="-L$(brew --prefix)/lib"; fi
[[ -d $GOPATH/bin ]] && path=("$GOPATH/bin" $path)
if command -v brew > /dev/null; then export CGO_LDFLAGS="-L$(brew --prefix)/lib"; fi
fi

# Add cargo to $PATH and turn on backtraces for Rust
export RUSTUP_HOME=${XDG_DATA_HOME:-$HOME/.local/share}/rustup
export CARGO_HOME=${XDG_DATA_HOME:-$HOME/.local/share}/cargo
[[ -d $CARGO_HOME/bin ]] && path=($CARGO_HOME/bin $path)
if which rustc > /dev/null; then export RUST_BACKTRACE=1; fi
[[ -d $CARGO_HOME/bin ]] && path=("$CARGO_HOME/bin" $path)
if command -v rustc > /dev/null; then export RUST_BACKTRACE=1; fi

# never generate .pyc files: it's slower, but maintains your sanity
if which python > /dev/null; then export PYTHONDONTWRITEBYTECODE=1; fi
if command -v python > /dev/null; then export PYTHONDONTWRITEBYTECODE=1; fi

# lazy load pyenv
export PYENV_ROOT=${PYENV_ROOT:-$HOME/.pyenv}
[[ -a $PYENV_ROOT/bin/pyenv ]] && path=($PYENV_ROOT/bin $path)
[[ -a "$PYENV_ROOT/bin/pyenv" ]] && path=("$PYENV_ROOT/bin" $path)
if type pyenv &> /dev/null || [[ -a $PYENV_ROOT/bin/pyenv ]]; then
function pyenv() {
unset pyenv
path=($PYENV_ROOT/shims $path)
path=("$PYENV_ROOT/shims" $path)
eval "$(command pyenv init -)"
if which pyenv-virtualenv-init > /dev/null; then
if command -v pyenv-virtualenv-init > /dev/null; then
eval "$(pyenv virtualenv-init -)"
export PYENV_VIRTUALENV_DISABLE_PROMPT=1
fi
pyenv $@
pyenv "$@"
}
fi

# lazy load rbenv
export RBENV_ROOT=${RBENV_ROOT:-$HOME/.rbenv}
[[ -a $RBENV_ROOT/bin/rbenv ]] && path=($RBENV_ROOT/bin $path)
[[ -a $RBENV_ROOT/bin/rbenv ]] && path=("$RBENV_ROOT/bin" $path)
if type rbenv &> /dev/null || [[ -a $RBENV_ROOT/bin/rbenv ]]; then
function rbenv() {
unset rbenv
path=($RBENV_ROOT/shims $path)
path=("$RBENV_ROOT/shims" $path)
eval "$(command rbenv init -)"
}
fi

# add airport to path
AIRPORT_PATH=/System/Library/PrivateFrameworks/Apple80211.framework/Resources
[[ -d "$AIRPORT_PATH" ]] && path=($AIRPORT_PATH $path)
[[ -d "$AIRPORT_PATH" ]] && path=("$AIRPORT_PATH" $path)

# global node installs (gross)
[[ -d "$XDG_DATA_HOME/node/bin" ]] && path=($XDG_DATA_HOME/node/bin $path)
[[ -d "$XDG_DATA_HOME/node/bin" ]] && path=("$XDG_DATA_HOME/node/bin" $path)

# pnpm global installs (slightly less gross)
if command -v pnpm > /dev/null; then
export PNPM_HOME="$XDG_DATA_HOME/pnpm"
path=("$PNPM_HOME" $path)
fi

# bun
if [[ -d ~/.bun ]]; then
source_if_exists ~/.bun/_bun
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
fi

# alias for accessing the docker host as a container
which docker > /dev/null && alias docker-host='docker run -it --rm --privileged --pid=host justincormack/nsenter1'

# kubernetes aliases
if which kubectl > /dev/null; then
function replaceNS() { kubectl config view --minify --flatten --context=$(kubectl config current-context) | yq ".contexts[0].context.namespace=\"$1\"" }
alias kks='KUBECONFIG=<(replaceNS "kube-system") kubectl'
alias kam='KUBECONFIG=<(replaceNS "authzed-monitoring") kubectl'
alias kas='KUBECONFIG=<(replaceNS "authzed-system") kubectl'
alias kar='KUBECONFIG=<(replaceNS "authzed-region") kubectl'
alias kt='KUBECONFIG=<(replaceNS "tenant") kubectl'
which kubectl-krew > /dev/null && path=($HOME/.krew/bin $path)
if command -v kubectl > /dev/null; then
alias -g kks="kubectl -n kube-system"
alias -g kam="kubectl -n authzed-monitoring"
alias -g kas="kubectl -n authzed-system"
alias -g kar="kubectl -n authzed-region"
alias -g kt="kubectl -n tenant"
which kubectl-krew > /dev/null && path=("$HOME/.krew/bin" $path)
function rmfinalizers() {
kubectl get deployment $1 -o json | jq '.metadata.finalizers = null' | k apply -f -
kubectl get deployment "$1" -o json | jq '.metadata.finalizers = null' | k apply -f -
}
fi

# gcloud
[[ -d $XDG_DATA_HOME/google-cloud-sdk ]] && export GCLOUD_SDK_PATH="$XDG_DATA_HOME/google-cloud-sdk"
if [[ -d $GCLOUD_SDK_PATH ]]; then
source_if_exists $GCLOUD_SDK_PATH/path.zsh.inc
source_if_exists $GCLOUD_SDK_PATH/completion.zsh.inc
source_if_exists "$GCLOUD_SDK_PATH/path.zsh.inc"
source_if_exists "$GCLOUD_SDK_PATH/completion.zsh.inc"
export USE_GKE_GCLOUD_AUTH_PLUGIN=True
fi

# time aliases
alias ber='TZ=Europe/Berlin date'
alias nyc='TZ=America/New_York date'
alias sfo='TZ=America/Los_Angeles date'
alias utc='TZ=Etc/UTC date'
alias -g ber='TZ=Europe/Berlin date'
alias -g nyc='TZ=America/New_York date'
alias -g sfo='TZ=America/Los_Angeles date'
alias -g utc='TZ=Etc/UTC date'

# theme for faq syntax highlighting
export FAQ_STYLE='github'
Loading

0 comments on commit b65643f

Please sign in to comment.