1
mirror of https://github.com/jakejarvis/dotfiles.git synced 2025-09-15 23:15:30 -04:00

a boatload of changes/fixes

This commit is contained in:
2025-02-07 11:09:17 -05:00
parent bab66d06a5
commit 21da506122
22 changed files with 6572 additions and 483 deletions

View File

@@ -1,5 +1,8 @@
#!/usr/bin/env zsh
# set DOTFILES_DEBUG to trace startup times (1/2)
[[ "$DOTFILES_DEBUG" != "1" ]] || zmodload zsh/zprof
# path to this directory:
export ZSH_CUSTOM=~/.dotfiles/zsh
@@ -12,10 +15,13 @@ done
unset _dotzsh
# macos.zsh has aliases, functions, etc specific to macOS:
if [[ "$OSTYPE" = "darwin"* ]] && [[ -f "$ZSH_CUSTOM"/custom/macos.zsh ]]; then
if [[ "$OSTYPE" = darwin* ]] && [[ -f "$ZSH_CUSTOM"/custom/macos.zsh ]]; then
source "$ZSH_CUSTOM"/custom/macos.zsh
fi
if [[ -f ~/.zshrc.local ]]; then
source ~/.zshrc.local
fi
# uncomment to debug startup time (2/2)
[[ "$DOTFILES_DEBUG" != "1" ]] || zprof

View File

@@ -11,6 +11,7 @@ alias l="ll"
# easier dotfile tinkering
alias shreload="exec \$SHELL"
alias shdebug="DOTFILES_DEBUG=1 exec \$SHELL"
# git
alias g="git"
@@ -37,36 +38,42 @@ alias gist="gh gist create --web"
# docker
alias dps="docker ps -a"
dbar() {
# build and run:
# build a Dockerfile in the current directory and run it interactively:
# https://stackoverflow.com/questions/45141402/build-and-run-dockerfile-with-one-command/59220656#59220656
docker build --progress=plain --no-cache . | tee /dev/tty | tail -n1 | cut -d' ' -f3 | xargs -I{} docker run --rm -i {}
docker run --rm -it "$(docker build --no-cache -q .)"
}
dsh() {
docker exec -it "$1" /bin/sh
}
# alias dc="docker-compose"
alias dc="docker compose"
alias dcu="docker compose up -d"
alias dcd="docker compose down"
alias dcr="docker compose down && docker compose up -d"
alias dcl="docker compose logs -f"
alias dcu="dc up -d"
alias dcd="dc down"
alias dcr="dcd && dcu"
alias dcl="dc logs -f"
# multipass
alias mp="multipass"
mpl() {
# creates VM and opens its bash shell
# `mpl test1 4G 20.04`
multipass launch "${2:-jammy}" --cpus 4 --mem "${3:-2G}" --disk 20G --name "$1" && \
multipass launch "${2:-jammy}" --cpus=4 --memory="${3:-2G}" --disk="${4:-20G}" --name="$1" && \
multipass shell "$1"
}
mpd() {
multipass delete "$1" && multipass purge
}
alias mpls="multipass list"
alias mpsh="multipass shell"
alias mpk="multipass stop"
alias mpd="multipass delete"
# Node/NPM/Yarn
alias npr="npm run"
alias yar="yarn run"
alias pnpr="pnpm run"
alias fresh_npm="rm -rf node_modules package-lock.json && npm install"
alias fresh_yarn="rm -rf node_modules yarn.lock && yarn install"
alias fresh_pnpm="rm -rf node_modules pnpm-lock.yaml && pnpm install"
# uncomment to use VS Code insiders build
# alias code="code-insiders"

View File

@@ -1,13 +1,21 @@
#!/usr/bin/env zsh
autoload -U colors && colors
autoload -U colors && \
colors
autoload -Uz url-quote-magic
zle -N self-insert url-quote-magic
autoload -Uz select-word-style
autoload -Uz select-word-style && \
select-word-style bash
# autoload -Uz bracketed-paste-magic && \
# zle -N bracketed-paste bracketed-paste-magic
# zstyle ':bracketed-paste-magic' active-widgets '.self-*'
autoload -Uz url-quote-magic && \
zle -N self-insert url-quote-magic
zstyle ":urlglobber" url-other-schema ftp git gopher http https magnet && \
export DISABLE_MAGIC_FUNCTIONS=true # make pasting into terminal faster
# enable bash-like 'help' command for zsh:
# https://stackoverflow.com/questions/4405382/how-can-i-read-documentation-about-built-in-zsh-commands
unalias run-help 2>/dev/null
@@ -17,31 +25,29 @@ alias help=run-help
# ---
setopt notify
setopt complete_aliases
setopt complete_in_word
setopt always_to_end
setopt extended_history
setopt hist_expire_dups_first
# setopt hist_ignore_dups
setopt hist_ignore_dups
setopt hist_ignore_space
setopt hist_verify
setopt share_history
setopt inc_append_history
setopt rc_quotes
setopt autocd
setopt extended_glob
setopt glob_dots
unsetopt case_glob
unsetopt beep # kindly stfu
unsetopt list_beep
unsetopt correct
unsetopt correct_all
# ---
bindkey -e
bindkey "^[^[[D" backward-word
bindkey "^[^[[C" forward-word
# ---
# kinda hacky way to traverse up to the root of the dotfiles repo
export DOTFILES="$(realpath "$(realpath "$(dirname "${0}")")/../..")"
export LC_ALL="${LC_ALL:-en_US.UTF-8}"
export LANG="${LANG:-en_US.UTF-8}"
@@ -55,7 +61,17 @@ export HISTSIZE=10000
export SAVEHIST=10000
export EDITOR="nano" # don't judge me
export VISUAL="code"
export VISUAL="code --new-window --wait"
export PAGER="less"
export LESS="$LESS -RF --mouse --silent"
# resolve GPG terminal at shell runtime
# fixes "signing failed: Inappropriate ioctl for device"
if tty -s 2>/dev/null; then
GPG_TTY=$(tty)
export GPG_TTY
fi
# https://github.com/ohmyzsh/ohmyzsh/blob/master/lib/theme-and-appearance.zsh#L5
# export LS_COLORS="Gxfxcxdxbxegedabagacad"

View File

@@ -1,11 +1,33 @@
#!/usr/bin/env zsh
# homebrew tweaks
export HOMEBREW_NO_ANALYTICS=1
export HOMEBREW_NO_ENV_HINTS=1
export HOMEBREW_NO_INSECURE_REDIRECT=1
# export HOMEBREW_CASK_OPTS=--require-sha
export NEXT_TELEMETRY_DISABLED=1
export GATSBY_TELEMETRY_DISABLED=1
export DOTNET_CLI_TELEMETRY_OPTOUT=1
export SAM_CLI_TELEMETRY=0
# docker tweaks
export DOCKER_BUILDKIT=1
export DOCKER_SCAN_SUGGEST=false
export COMPOSE_DOCKER_CLI_BUILD=1
# npm tweaks
export DISABLE_OPENCOLLECTIVE=1
export NO_UPDATE_NOTIFIER=1
export NPM_CONFIG_FUND=false
export NPM_CONFIG_UPDATE_NOTIFIER=false
export OPEN_SOURCE_CONTRIBUTOR=true
export OPENCOLLECTIVE_HIDE=1
# can everyone stop being so creepy pls
export AZURE_CORE_COLLECT_TELEMETRY=0
export CHECKPOINT_DISABLE=1
export CLI_COLLECT_METRICS=0
export CLOUDSDK_CORE_DISABLE_USAGE_REPORTING=true
export DOTNET_CLI_TELEMETRY_OPTOUT=true
export GATSBY_TELEMETRY_DISABLED=1
export NEXT_TELEMETRY_DISABLED=1
export POWERSHELL_TELEMETRY_OPTOUT=1
export SAM_CLI_TELEMETRY=0
export SLS_TELEMETRY_DISABLED=1
export VAGRANT_CHECKPOINT_DISABLE=1
export YARN_ENABLE_TELEMETRY=0

View File

@@ -2,8 +2,18 @@
# Make a new directory and `cd` right into it (this seems like a no-brainer)
mkcd() {
mkdir -p -- "$1" &&
cd -P -- "$1" || return
mkdir -p "$1" && cd "$1"
}
# Load .env file into shell session for environment variables
# https://github.com/thoughtbot/dotfiles/blob/main/zsh/functions/envup
envup() {
if [ -f .env ]; then
export $(sed '/^ *#/ d' .env)
else
echo 'No .env file found' 1>&2
return 1
fi
}
# Start an HTTP server from a directory, optionally specifying the port
@@ -61,6 +71,13 @@ extract() {
fi
}
# create a jrvs.io short URL
# ex: short https://github.com/jakejarvis/dotfiles jakesdotfiles => https://jrvs.io/jakesdotfiles
# https://github.com/jakejarvis/jrvs.io/blob/main/short.sh
short() {
( cd "$HOME/source/jrvs.io" && bash -c "./short.sh $*" )
}
# Create a git.io short URL (custom slug optional)
# ex: gitio https://github.com/jakejarvis/dotfiles [jakesdotfiles] => https://git.io/jakesdotfiles
# https://blog.github.com/2011-11-10-git-io-github-url-shortener

View File

@@ -1,7 +1,15 @@
#!/usr/bin/env zsh
export BROWSER="/Applications/Firefox.app/Contents/MacOS/firefox"
# export BROWSER="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"
# https://developer.1password.com/docs/ssh/get-started#step-4-configure-your-ssh-or-git-client
if [[ -S "$HOME/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock" ]]; then
export SSH_AUTH_SOCK="$HOME/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock"
fi
export HOMEBREW_CASK_OPTS="--appdir=/Applications" # --require-sha
export HOMEBREW_FORCE_BREWED_CURL=1
export HOMEBREW_FORCE_BREWED_GIT=1
# Rosetta hacks for M1
alias intel="arch -x86_64 /bin/zsh"
@@ -16,17 +24,13 @@ system_update() {
brew update
brew upgrade
# avoid annoying `(latest) != latest` cask updates:
# shellcheck disable=SC2046
brew upgrade $(brew outdated --greedy --verbose | awk '$2 !~ /(latest)/ {print $1}')
brew cleanup
# node, npm, yarn
echo -e "${YELLOW}Updating global NPM/Yarn packages...${NC}"
volta fetch node@latest # pull latest non-LTS version but don't use it
volta install node@lts
volta install yarn@1
volta run --node lts --no-yarn -- npm update --global
volta run --node lts --yarn 1 -- yarn global upgrade
fnm install --latest --corepack-enabled
npm update --global --no-audit
# ruby, gems
echo -e "${YELLOW}Updating Ruby and gems...${NC}"
@@ -43,6 +47,11 @@ system_update() {
echo -e "${YELLOW}Updating pip packages...${NC}"
pip3 list --outdated --format=json | jq -r '.[] | .name+"="+.latest_version' | cut -d = -f 1 | xargs -n1 pip3 install -U
# zinit & plugins
echo -e "${YELLOW}Updating zinit...${NC}"
zinit self-update
zinit update --all
# App Store
echo -e "${YELLOW}Checking for App Store updates...${NC}"
mas outdated
@@ -50,20 +59,16 @@ system_update() {
# macOS system
echo -e "${YELLOW}Checking for macOS system updates...${NC}"
softwareupdate --list
# zinit & plugins
echo -e "${YELLOW}Updating zinit...${NC}"
zinit self-update
zinit update --all
}
alias rehide="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"
alias unhide="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
alias unhidden="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
alias rehidden="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"
alias force_empty="sudo rm -rf ~/.Trash /Volumes/*/.Trashes"
alias unq="sudo xattr -rd com.apple.quarantine"
alias gpu="system_profiler SPDisplaysDataType"
alias cpu="sysctl -n machdep.cpu.brand_string"
# hide/show all desktop icons (useful when presenting)
alias hidedesk="defaults write com.apple.finder CreateDesktop -bool false && killall Finder"
alias showdesk="defaults write com.apple.finder CreateDesktop -bool true && killall Finder"
alias ripfinder="killall Finder"
alias ripdock="killall Dock"
@@ -83,9 +88,8 @@ alias flush="sudo killall -HUP mDNSResponder; sudo killall mDNSResponderHelper;
alias ios_sim="open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app"
alias watchos_sim="open /Applications/Xcode.app/Contents/Developer/Applications/Simulator\ \(Watch\).app"
# convenient access to public key
# convenient access to ssh public key
alias pubkey="pbcopy < ~/.ssh/id_ed25519.pub && echo '=> Public key copied to clipboard.'"
alias pubkey_rsa="pbcopy < ~/.ssh/id_rsa.pub && echo '=> Public key copied to clipboard.'"
# workaround for lack of tailscale CLI on mac:
# https://tailscale.com/kb/1080/cli/?tab=macos#using-the-cli

View File

@@ -1,76 +1,132 @@
#!/usr/bin/env zsh
# set PATH, MANPATH, etc., for Homebrew
if [[ -x /opt/homebrew/bin/brew ]]; then
# Homebrew's location is different depending on OS...
# https://github.com/Homebrew/install/blob/master/install.sh#L122
if [[ -d /opt/homebrew ]]; then
# macOS on Apple Silicon
eval "$(/opt/homebrew/bin/brew shellenv)"
elif [[ -x /usr/local/bin/brew ]]; then
# macOS on x86
eval "$(/opt/homebrew/bin/brew shellenv)"
elif [[ -d /home/linuxbrew/.linuxbrew ]]; then
# Linux, system install
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
BREW_BIN="/opt/homebrew/bin/brew"
elif [[ -d "$HOME/.linuxbrew" ]]; then
# Linux, user install
eval "$("$HOME/.linuxbrew/bin/brew" shellenv)"
# NOTE: definitely discouraged, maybe deprecated? https://github.com/Homebrew/install/pull/702
BREW_BIN="$HOME/.linuxbrew/bin/brew"
elif [[ -d /home/linuxbrew/.linuxbrew ]]; then
# Linux, system install
BREW_BIN="/home/linuxbrew/.linuxbrew/bin/brew"
else
# macOS on Intel (hopefully, or else we're kinda doomed...)
BREW_BIN="/usr/local/bin/brew"
fi
# a lot of this file only applies to macOS
if [[ "$OSTYPE" = "darwin"* ]]; then
# remap macOS core utils to GNU equivalents (from coreutils, findutils, gnu-*, etc.):
# https://gist.github.com/skyzyx/3438280b18e4f7c490db8a2a2ca0b9da?permalink_comment_id=3049694#gistcomment-3049694
if command -v brew &>/dev/null; then
for gbin in "$(brew --prefix)"/opt/*/libexec/gnubin; do
export PATH="$gbin:$PATH"
# set PATHs for Homebrew (if we found it)
if [[ -x "$BREW_BIN" ]]; then
eval "$("$BREW_BIN" shellenv)"
# macOS-only remedies
if [[ "$OSTYPE" = darwin* ]]; then
# manually add VS Code 'code' command to path
# https://code.visualstudio.com/docs/setup/mac#_alternative-manual-instructions
if [[ -d "/Applications/Visual Studio Code.app/Contents/Resources/app/bin" ]]; then
path=("/Applications/Visual Studio Code.app/Contents/Resources/app/bin" $path)
fi
# remap macOS core utils to GNU equivalents without needing the 'g' prefix (e.g. ggrep -> grep):
# https://gist.github.com/skyzyx/3438280b18e4f7c490db8a2a2ca0b9da?permalink_comment_id=3049694#gistcomment-3049694
for gnubin in "$(brew --prefix)"/opt/*/libexec/gnubin; do
path=($gnubin $path)
done
# Ensure `man` refers to the new binaries:
for gman in "$(brew --prefix)"/opt/*/libexec/gnuman; do
export MANPATH="$gman:$MANPATH"
# ensure man also points to the GNU manuals
for gnuman in "$(brew --prefix)"/opt/*/libexec/gnuman; do
manpath=($gnuman $manpath)
done
unset gbin gman
# shellcheck disable=SC2155
export HELPDIR="$(brew --prefix)/share/zsh/help"
# declare the base xcode & homebrew paths first
LDFLAGS="${LDFLAGS:+"$LDFLAGS "}-L$(brew --prefix)/lib"
CFLAGS="${CPPFLAGS:+"$CPPFLAGS "}-I$(brew --prefix)/include -I$(brew --prefix openjdk)/include"
PKG_CONFIG_PATH="${PKG_CONFIG_PATH:+${PKG_CONFIG_PATH}:}$(brew --prefix)/lib/pkgconfig"
# OpenJDK
# shellcheck disable=SC2155
export PATH="$(brew --prefix)/opt/openjdk/bin:$PATH"
# tell compilers and pkg-config where to find the homebrew versions (rather than the vendored macOS versions) of the
# following packages:
declare -a compiler_libs=(
bzip2
curl
jemalloc
libffi
gettext
libxml2
ncurses
openssl@1.1
readline
sqlite
tcl-tk
icu4c
xz
zlib
)
# macOS-only fixes for rbenv/ruby below
# shellcheck disable=SC2155
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1) --with-readline-dir=$(brew --prefix readline) --with-libyaml-dir=$(brew --prefix libyaml) --with-jemalloc-dir=$(brew --prefix jemalloc)"
# append the specific paths for each of the above libraries
for lib in $compiler_libs; do
# TODO: 'brew --prefix' got pretty slow in Homebrew v4, so these calls should be cleaned up/optimized
# https://github.com/Homebrew/brew/commit/ca32473a672ef08be60792a921a3a1e4dcc32e13
LDFLAGS+=" -L$(brew --prefix $lib)/lib"
CFLAGS+=" -I$(brew --prefix $lib)/include"
PKG_CONFIG_PATH+=":$(brew --prefix $lib)/lib/pkgconfig"
done
# tell compilers where to find all of this stuff
# shellcheck disable=SC2155
export LDFLAGS="$LDFLAGS -L$(brew --prefix openssl@1.1)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix jemalloc)/lib"
# shellcheck disable=SC2155
export CPPFLAGS="$CPPFLAGS -I$(brew --prefix openjdk)/include -I$(brew --prefix openssl@1.1)/include -I$(brew --prefix readline)/include -I$(brew --prefix jemalloc)/include"
# it's easier to do ruby opts separately as it needs different libraries than above in a very different format
RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1) --with-readline-dir=$(brew --prefix readline) --with-jemalloc-dir=$(brew --prefix jemalloc) --with-libffi-dir=$(brew --prefix libffi) --with-libyaml-dir=$(brew --prefix libyaml) $RUBY_CONFIGURE_OPTS"
# add xcode flags last
if command -v xcrun &>/dev/null; then
LDFLAGS+=" -L$(xcrun --show-sdk-path)/usr/lib"
CFLAGS+=" -I$(xcrun --show-sdk-path)/usr/include"
PKG_CONFIG_PATH+=":$(brew --prefix $lib)/lib/pkgconfig"
fi
# finally all done with this mess
export LDFLAGS CPPFLAGS PKG_CONFIG_PATH RUBY_CONFIGURE_OPTS
unset gnubin gnuman compiler_libs lib
fi
else
echo "⚠️ Homebrew can't be found in any of the normal locations. Are you sure it's installed?"
fi
# go
if [[ -d "$HOME/golang" ]]; then
export GOPATH="$HOME/golang"
export PATH="$GOPATH/bin:$PATH"
path=("$GOPATH/bin" $path)
fi
# rust/cargo
if [[ -d "$HOME/.cargo" ]]; then
export PATH="$HOME/.cargo/bin:$PATH"
path=("$HOME/.cargo/bin" $path)
fi
# fnm
if command -v fnm &>/dev/null; then
eval "$(fnm env --use-on-cd --shell zsh)"
fi
# rbenv
if command -v rbenv &>/dev/null; then
eval "$(rbenv init --no-rehash - zsh)"
eval "$(rbenv init - --no-rehash zsh)"
fi
# pyenv
if command -v pyenv &>/dev/null; then
eval "$(pyenv init --no-rehash - zsh)"
eval "$(pyenv init - --no-rehash zsh)"
# pyenv-virtualenv
if command -v pyenv-virtualenv-init &>/dev/null; then
eval "$(pyenv virtualenv-init - zsh)"
fi
fi
# volta
if [[ -d "$HOME/.volta" ]]; then
export VOLTA_HOME="$HOME/.volta"
export PATH="$VOLTA_HOME/bin:$PATH"
# docker user mode, see: https://docs.docker.com/desktop/mac/permission-requirements/#installing-symlinks
if [[ -d "$HOME/.docker/bin" ]]; then
path=("$HOME/.docker/bin" $path)
fi
# let zsh sort out formatting and deduplication
typeset -aU path fpath manpath
export PATH FPATH MANPATH

View File

@@ -1,42 +1,48 @@
#!/usr/bin/env zsh
# check for zinit and clone if not installed
ZINIT_HOME="$HOME/.local/share/zinit/zinit.git"
if [[ ! -d "$ZINIT_HOME" ]]; then
mkdir -p "$(dirname "$ZINIT_HOME")"
git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
# these custom values must be set *before* sourcing zinit
export ZINIT_HOME="${ZINIT_HOME:-"${XDG_DATA_HOME:-"${HOME}/.local/share"}/zinit/zinit.git"}"
declare -A ZINIT=(
[ZCOMPDUMP_PATH]="${XDG_CACHE_HOME:-"$HOME/.cache"}/zsh/.zcompdump-$ZSH_VERSION"
)
# check for zinit
if [[ -f "$ZINIT_HOME/zinit.zsh" ]]; then
source "$ZINIT_HOME/zinit.zsh"
else
echo "zinit not found in '$ZINIT_HOME', either check the value of ZINIT_HOME or install zinit."
return
fi
# initialize zinit
# shellcheck disable=SC1091
source "$ZINIT_HOME/zinit.zsh"
# ensure compinit recognizes zinit's changes
# initialize zinit && ensure compinit recognizes its completions
autoload -Uz _zinit
# shellcheck disable=SC2154
(( ${+_comps} )) && _comps[zinit]=_zinit
# TODO: figure out why zinit stopped adding itself to MANPATH automatically...
if [[ -d "${ZINIT[MAN_DIR]}" ]]; then
manpath=(
"${ZINIT[MAN_DIR]}"
$manpath
)
fi
# various zinit add-ons
zinit light zdharma-continuum/zinit-annex-patch-dl
# oh-my-zsh was good at setting iTerm tab titles, keep doing it pls
# https://github.com/ohmyzsh/ohmyzsh/tree/master/lib
zinit snippet OMZ::lib/functions.zsh
zinit snippet OMZ::lib/termsupport.zsh
zinit snippet OMZ::lib/compfix.zsh
# async support
zinit ice wait lucid \
zinit ice lucid depth"1" \
atload"async_init" \
src"async.zsh"
zinit light mafredri/zsh-async
# z
zinit ice wait lucid blockf \
atclone"
mv -vf z.1 ${ZINIT[MAN_DIR]}/man1
" \
atpull"%atclone" \
atload"_Z_DATA=~/.zdata" \
src"z.sh"
zinit light rupa/z
# grab exa (better ls) binary
zinit ice from"gh-r" as"command" \
zinit ice lucid from"gh-r" as"command" \
mv"bin/exa* -> exa" \
atclone"
mv -vf completions/exa.zsh _exa
@@ -52,7 +58,7 @@ zinit ice from"gh-r" as"command" \
zinit light ogham/exa
# grab bat (better cat) binary
zinit ice from"gh-r" as"command" \
zinit ice lucid from"gh-r" as"command" \
mv"bat-*/bat -> bat" \
atclone"
mv -vf bat-*/autocomplete/bat.zsh _bat
@@ -61,95 +67,121 @@ zinit ice from"gh-r" as"command" \
atpull"%atclone" \
atload"
export BAT_THEME='base16'
export BAT_PAGER='less -R -F -+X --mouse'
export MANPAGER='sh -c \"col -bx | bat --color=always --style=plain --language=man\"'
alias cat='bat --paging=never --color=auto --style=numbers,changes'
alias cats='bat --paging=always --color=always --style=numbers,changes'
alias catcat='\cat --paging=never --color=auto --style=plain'
alias cat='bat --paging=always --color=auto --style=numbers,changes'
alias plcat='bat --paging=never --color=auto --style=plain'
"
zinit light sharkdp/bat
# grab delta binary
zinit ice from"gh-r" as"command" \
zinit ice lucid from"gh-r" as"command" \
mv"delta-*/delta -> delta" \
dl"https://github.com/dandavison/delta/raw/HEAD/etc/completion/completion.zsh -> _delta" \
atload"
# https://dandavison.github.io/delta/mouse-scrolling.html
export DELTA_PAGER='less -R -F -+X --mouse'
"
dl"https://github.com/dandavison/delta/raw/HEAD/etc/completion/completion.zsh -> _delta"
zinit light dandavison/delta
# grab fd binary
# TODO: preview commands are an absolute sh*tshow, maybe use .lessfilter?
# https://github.com/Aloxaf/fzf-tab/wiki/Preview#show-file-contents
# shellcheck disable=SC2016
zinit ice from"gh-r" as"command" \
zinit ice lucid from"gh-r" as"command" \
mv"fd-*/fd -> fd" \
atclone"
mv -vf fd-*/autocomplete/_fd _fd
mv -vf fd-*/fd.1 ${ZINIT[MAN_DIR]}/man1
" \
atpull"%atclone" \
atload'
FZF_FD_OPTS="--color always --hidden --follow --exclude .git --exclude node_modules"
FZF_PREVIEW_FILE_COMMAND="bat --color=always --paging=never --style=plain"
FZF_PREVIEW_DIR_COMMAND="exa -1a --color=always --icons --group-directories-first"
FZF_DEFAULT_OPTS="--no-mouse --bind \"tab:accept,ctrl-y:preview-page-up,ctrl-v:preview-page-down,ctrl-e:execute-silent(\${VISUAL:-code} {+} >/dev/null 2>&1)\""
FZF_DEFAULT_COMMAND="fd --type f $FZF_FD_OPTS"
FZF_ALT_C_OPTS="--ansi --preview \"$FZF_PREVIEW_DIR_COMMAND {} 2>/dev/null\""
FZF_ALT_C_COMMAND="fd --type d . $FZF_FD_OPTS"
FZF_CTRL_T_OPTS="--ansi --bind \"ctrl-w:execute(\${EDITOR:-nano} {1} >/dev/tty </dev/tty)+refresh-preview\" --preview \"$FZF_PREVIEW_FILE_COMMAND {} 2>/dev/null\""
FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
'
atpull"%atclone"
zinit light sharkdp/fd
# grab fzf binary from release & other files from source
zinit ice from"gh-r" as"command" \
# TODO: preview commands are an absolute sh*tshow, maybe use .lessfilter?
# https://github.com/Aloxaf/fzf-tab/wiki/Preview#show-file-contents
zinit ice lucid from"gh-r" as"command" \
dl"https://github.com/junegunn/fzf/raw/HEAD/shell/key-bindings.zsh -> key-bindings.zsh" \
dl"https://github.com/junegunn/fzf/raw/HEAD/shell/completion.zsh -> _fzf" \
dl"https://github.com/junegunn/fzf/raw/HEAD/man/man1/fzf.1 -> ${ZINIT[MAN_DIR]}/man1/fzf.1" \
dl"https://github.com/junegunn/fzf/raw/HEAD/man/man1/fzf-tmux.1 -> ${ZINIT[MAN_DIR]}/man1/fzf-tmux.1" \
atload'
export FZF_FD_OPTS="--color always --hidden --follow --exclude .git --exclude node_modules"
export FZF_PREVIEW_FILE_COMMAND="bat --color=always --paging=never --style=plain"
export FZF_PREVIEW_DIR_COMMAND="exa -1a --color=always --icons --group-directories-first"
export FZF_DEFAULT_OPTS="--cycle --select-1 --exit-0 --height=60% --no-mouse --bind=\"tab:accept,ctrl-y:preview-page-up,ctrl-v:preview-page-down,ctrl-e:execute-silent(\${VISUAL:-\$EDITOR} {+} >/dev/null 2>&1)\""
export FZF_DEFAULT_COMMAND="fd --type f $FZF_FD_OPTS"
export FZF_ALT_C_OPTS="-i --ansi --preview=\"$FZF_PREVIEW_DIR_COMMAND {}\""
export FZF_ALT_C_COMMAND="fd --type d . $FZF_FD_OPTS"
export FZF_CTRL_T_OPTS="-i --ansi --bind=\"ctrl-w:execute(\$EDITOR {1} >/dev/tty </dev/tty)+refresh-preview\" --preview=\"$FZF_PREVIEW_FILE_COMMAND {} 2>/dev/null\""
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
' \
src"key-bindings.zsh"
zinit light junegunn/fzf
# zoxide
zinit ice wait"0b" lucid from"gh-r" as"command" \
atclone"
mv -vf man/man1/zoxide* ${ZINIT[MAN_DIR]}/man1
./zoxide init zsh > init.zsh
zcompile init.zsh
" \
atpull"%atclone" \
atinit'
export _ZO_DATA_DIR="${XDG_DATA_HOME:-"$HOME/.local/share"}/zoxide"
export _ZO_FZF_OPTS="$FZF_DEFAULT_OPTS --exact --no-sort --ansi --reverse --preview=\"$FZF_PREVIEW_DIR_COMMAND {2..}\""
' \
src"init.zsh"
zinit light ajeetdsouza/zoxide
# grab vivid binary (for all the colors)
# https://github.com/sharkdp/vivid/tree/master/themes
# shellcheck disable=SC2016
zinit ice from"gh-r" as"command" \
# by outputting the generated LS_COLORS variable to a file and sourcing it, we only need to call vivid once on
# installation rather than every time a new session begins.
zinit ice lucid from"gh-r" as"command" \
mv"vivid-*/vivid -> vivid" \
atload'export LS_COLORS="$(vivid generate snazzy)"'
zinit load sharkdp/vivid
atclone"
./vivid generate snazzy | xargs printf 'export LS_COLORS=%q' > colors.zsh
" \
atpull"%atclone" \
atload"zstyle ':completion:*' list-colors \${(s.:.)LS_COLORS}" \
src"colors.zsh"
zinit light sharkdp/vivid
# history substring searching
# only bind these keys once they're ready
bindkey -r "^[[A"
bindkey -r "^[[B"
zinit ice wait lucid \
# better Ctrl+R history searching
zinit ice wait lucid depth"1" \
atload"
zmodload zsh/terminfo
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
"
zinit light zsh-users/zsh-history-substring-search
zstyle ':history-search-multi-word' highlight-color 'fg=yellow,bold'
zstyle ':history-search-multi-word' page-size 15
zstyle ':plugin:history-search-multi-word' active 'standout'
zstyle ':plugin:history-search-multi-word' reset-prompt-protect 1
" \
trackbinds
zinit light zdharma-continuum/history-search-multi-word
# tab completions via fzf
zinit ice wait"1" lucid \
zinit ice wait"0b" lucid depth"1" \
has"fzf" \
blockf \
atpull"zinit creinstall -q ." \
atload"
zstyle ':completion:*' verbose yes
zstyle ':completion:*' list-colors \${(s.:.)LS_COLORS}
zstyle ':completion:*:descriptions' format '[%d]'
zstyle ':completion::complete:*:*:files' ignored-patterns '.DS_Store' 'Icon?' '.Trash'
zstyle ':completion::complete:*:*:globbed-files' ignored-patterns '.DS_Store' 'Icon?' '.Trash'
zstyle ':completion:*' verbose true
zstyle ':completion:*' use-cache true
zstyle ':completion:*' cache-path '$(dirname ${ZINIT[ZCOMPDUMP_PATH]})/.zcompcache'
zstyle ':completion:*' rehash true
zstyle ':completion:*' squeeze-slashes true
zstyle ':completion:*' list-dirs-first true
zstyle ':completion:*' keep-prefix true
zstyle ':completion:*' special-dirs true
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
zstyle ':completion:*' menu select
zstyle ':completion:*' group-name ''
zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s'
zstyle ':completion:*:descriptions' format '%d'
zstyle ':completion:*:functions' ignored-patterns '_*'
zstyle ':completion::complete:*:*:files' ignored-patterns '.DS_Store' 'Icon?'
zstyle ':completion::complete:*:*:globbed-files' ignored-patterns '.DS_Store' 'Icon?'
zstyle ':completion::complete:rm:*:globbed-files' ignored-patterns
zstyle ':fzf-tab:*' fzf-command fzf
zstyle ':fzf-tab:*' fzf-flags '--ansi'
zstyle ':fzf-tab:*' fzf-command 'fzf'
zstyle ':fzf-tab:*' fzf-flags $FZF_DEFAULT_OPTS '-i' '--ansi'
zstyle ':fzf-tab:*' fzf-bindings \
'tab:accept' \
'ctrl-y:preview-page-up' \
'ctrl-v:preview-page-down' \
'ctrl-e:execute-silent(\${VISUAL:-code} \$realpath >/dev/null 2>&1)' \
'ctrl-w:execute(\${EDITOR:-nano} \$realpath >/dev/tty </dev/tty)+refresh-preview'
'ctrl-e:execute-silent(\${VISUAL:-\$EDITOR} \$realpath >/dev/null 2>&1)' \
'ctrl-w:execute(\$EDITOR \$realpath >/dev/tty </dev/tty)+refresh-preview'
zstyle ':fzf-tab:*' fzf-min-height 15
zstyle ':fzf-tab:complete:git-(add|diff|restore):*' fzf-preview \
'git diff --no-ext-diff \$word | delta --paging=never --no-gitconfig --line-numbers --file-style=omit --hunk-header-style=omit --theme=base16'
@@ -170,86 +202,138 @@ zinit ice wait"1" lucid \
"
zinit light Aloxaf/fzf-tab
# TODO: fix git-* completions, apparently there's some conflict with brew's git
# https://github.com/Aloxaf/fzf-tab/wiki/Preview#git
# shellcheck disable=SC2016
zinit ice wait lucid as"completions" \
id-as"git-completions" \
has"git" \
dl"https://github.com/git/git/raw/HEAD/contrib/completion/git-completion.zsh -> _git" \
dl"https://github.com/git/git/raw/HEAD/contrib/completion/git-completion.bash -> git-completion.bash" \
# fix git-* completions, apparently there's some conflict with brew's git
# TODO: investigate more... https://github.com/Aloxaf/fzf-tab/wiki/Preview#git
zinit ice wait lucid as"null" \
atload'zstyle ":completion:*:*:git:*" script "$(pwd)/git-completion.bash"'
zinit snippet https://github.com/git/git/raw/HEAD/contrib/completion/git-completion.bash
# grab completions as snippets from GitHub repos
zinit wait lucid as"completion" \
atpull"zinit creinstall -q ." \
atload'
zstyle ":completion:*:*:git:*" script "$PWD/git-completion.bash"
' \
nocompile
nocompile \
for \
has"bundle" https://github.com/zsh-users/zsh-completions/raw/HEAD/src/_bundle \
has"conda" https://github.com/conda-incubator/conda-zsh-completion/raw/HEAD/_conda \
has"docker" https://github.com/docker/cli/raw/HEAD/contrib/completion/zsh/_docker \
has"golang" https://github.com/zsh-users/zsh-completions/raw/HEAD/src/_golang \
has"nano" https://github.com/zsh-users/zsh-completions/raw/HEAD/src/_nano \
has"node" https://github.com/zsh-users/zsh-completions/raw/HEAD/src/_node \
has"nvm" https://github.com/zsh-users/zsh-completions/raw/HEAD/src/_nvm \
has"psql" https://github.com/zsh-users/zsh-completions/raw/HEAD/src/_pgsql_utils \
has"rails" https://github.com/zsh-users/zsh-completions/raw/HEAD/src/_rails \
has"rbenv" https://github.com/rbenv/rbenv/raw/HEAD/completions/_rbenv \
has"redis-cli" https://github.com/zsh-users/zsh-completions/raw/HEAD/src/_redis-cli \
has"shellcheck" https://github.com/zsh-users/zsh-completions/raw/HEAD/src/_shellcheck \
has"vagrant" https://github.com/hashicorp/vagrant/raw/HEAD/contrib/zsh/_vagrant \
has"yarn" https://github.com/zsh-users/zsh-completions/raw/HEAD/src/_yarn \
has"git" mv"git-completion.zsh -> _git" https://github.com/git/git/raw/HEAD/contrib/completion/git-completion.zsh \
has"pyenv" mv"pyenv.zsh -> _pyenv" https://github.com/pyenv/pyenv/raw/HEAD/completions/pyenv.zsh \
if'[[ "$OSTYPE" = linux-gnu* ]]' has"fail2ban-client" https://github.com/zsh-users/zsh-completions/raw/HEAD/src/_fail2ban-client \
if'[[ "$OSTYPE" = linux-gnu* ]]' has"ufw" https://github.com/zsh-users/zsh-completions/raw/HEAD/src/_ufw \
if'[[ "$OSTYPE" = darwin* ]]' has"security" https://github.com/ohmyzsh/ohmyzsh/raw/HEAD/plugins/macos/_security \
# generate other completions from externally installed programs
zinit wait lucid as"completion" \
atpull"zinit creinstall -q ." \
nocompile \
for \
has"doctl" id-as"_local/completions/doctl" atclone"doctl completion zsh > _doctl" zdharma-continuum/null \
has"fnm" id-as"_local/completions/fnm" atclone"fnm completions --shell zsh > _fnm" zdharma-continuum/null \
has"gh" id-as"_local/completions/gh" atclone"gh completion -s zsh > _gh" zdharma-continuum/null \
has"glab" id-as"_local/completions/glab" atclone"glab completion -s zsh > _glab" zdharma-continuum/null \
has"helm" id-as"_local/completions/helm" atclone"helm completion zsh > _helm" zdharma-continuum/null \
has"hugo" id-as"_local/completions/hugo" atclone"hugo completion zsh > _hugo" zdharma-continuum/null \
has"kubectl" id-as"_local/completions/kubectl" atclone"kubectl completion zsh > _kubectl" zdharma-continuum/null \
has"minikube" id-as"_local/completions/minikube" atclone"minikube completion zsh > _minikube" zdharma-continuum/null \
has"ng" id-as"_local/completions/ng" atclone"ng completion script > _ng" zdharma-continuum/null \
has"op" id-as"_local/completions/op" atclone"op completion zsh > _op" zdharma-continuum/null \
has"pip" id-as"_local/completions/pip" atclone"pip completion --zsh > pip" zdharma-continuum/null \
has"pnpm" id-as"_local/completions/pnpm" atclone"pnpm completion zsh > _pnpm" zdharma-continuum/null \
has"pscale" id-as"_local/completions/pscale" atclone"pscale completion zsh > _pscale" zdharma-continuum/null \
has"rustup" id-as"_local/completions/rustup" atclone"rustup completions zsh > _rustup" zdharma-continuum/null \
has"supabase" id-as"_local/completions/supabase" atclone"supabase completion zsh > _supabase" zdharma-continuum/null \
has"tailscale" id-as"_local/completions/tailscale" atclone"tailscale completion zsh > _tailscale" zdharma-continuum/null
# fix git-* completions, apparently there's some conflict with brew's git
# TODO: investigate more... https://github.com/Aloxaf/fzf-tab/wiki/Preview#git
zinit ice wait lucid as"null" \
atload'zstyle ":completion:*:*:git:*" script "$(pwd)/git-completion.bash"'
zinit snippet https://github.com/git/git/raw/HEAD/contrib/completion/git-completion.bash
# macOS-only completion fixes
zinit ice wait lucid as"null" \
id-as"_local/extra/mac" \
if'[[ "$OSTYPE" = darwin* ]]' \
atload"
zstyle ':completion:*:*:*:*:processes' command 'ps -o comm=\"\" -w -w'
zstyle ':fzf-tab:complete:(kill|ps):argument-rest' fzf-preview \
'[[ \$group == \"process ID\" ]] && ps -p\$word -o comm=\"\" -w -w'
"
zinit light zdharma-continuum/null
# use zinit to track completions from non-zinit programs
zinit ice wait lucid blockf as"completions" \
id-as"local-completions" \
dl"https://github.com/docker/cli/raw/HEAD/contrib/completion/zsh/_docker -> _docker" \
dl"https://github.com/docker/compose/raw/master/contrib/completion/zsh/_docker-compose -> _docker-compose" \
dl"https://github.com/zsh-users/zsh-completions/raw/HEAD/src/_node -> _node" \
dl"https://github.com/zsh-users/zsh-completions/raw/HEAD/src/_yarn -> _yarn" \
dl"https://github.com/zsh-users/zsh-completions/raw/HEAD/src/_bundle -> _bundle" \
dl"https://github.com/zsh-users/zsh-completions/raw/HEAD/src/_rails -> _rails" \
dl"https://github.com/zsh-users/zsh-completions/raw/HEAD/src/_golang -> _golang" \
dl"https://github.com/zsh-users/zsh-completions/raw/HEAD/src/_shellcheck -> _shellcheck" \
dl"https://github.com/zsh-users/zsh-completions/raw/HEAD/src/_httpie -> _httpie" \
dl"https://github.com/rbenv/rbenv/raw/HEAD/completions/rbenv.zsh -> _rbenv" \
dl"https://github.com/pyenv/pyenv/raw/HEAD/completions/pyenv.zsh -> _pyenv" \
atclone"
command -v volta &>/dev/null && volta completions zsh > _volta || true
command -v npm &>/dev/null && npm completion > _npm || true
command -v gh &>/dev/null && gh completion -s zsh > _gh || true
command -v op &>/dev/null && op completion zsh > _op || true
command -v hugo &>/dev/null && hugo completion zsh > _hugo || true
" \
atpull"zinit creinstall -q ." \
nocompile
# Linux-only completion fixes
zinit ice wait lucid as"null" \
id-as"_local/extra/linux" \
if'[[ "$OSTYPE" = linux-gnu* ]]' \
atload"
zstyle ':completion:*:*:*:*:processes' command 'ps -o cmd --no-headers -w -w'
zstyle ':fzf-tab:complete:(kill|ps):argument-rest' fzf-preview \
'[[ \$group == \"process ID\" ]] && ps --pid=\$word -o cmd --no-headers -w -w'
zstyle ':fzf-tab:complete:systemctl-*:*' fzf-preview 'SYSTEMD_COLORS=1 systemctl status \$word'
"
zinit light zdharma-continuum/null
# additional completions
# zinit ice wait lucid blockf as"completion" \
# atpull"zinit creinstall -q ."
# zinit light zsh-users/zsh-completions
# autopairing of quotes, brackets, etc.
zinit ice wait"0b" lucid depth"1" \
atload"ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(autopair-insert)"
zinit light hlissner/zsh-autopair
# syntax highlighting
zinit ice wait lucid depth"1" \
atinit"ZINIT[COMPINIT_OPTS]=-C; zicompinit; zicdreplay" \
atload"
zle_highlight+=('paste:reverse')
zstyle ':plugin:fast-syntax-highlighting' theme ''
typeset -gA FAST_HIGHLIGHT_STYLES
FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME:-}variable]='fg=cyan,bold'
"
zinit light zdharma-continuum/fast-syntax-highlighting
# autosuggestions, trigger precmd hook upon load
zinit ice wait lucid \
zinit ice wait"0a" lucid depth"1" \
atinit"
export ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20
export ZSH_AUTOSUGGEST_MANUAL_REBIND=1
export ZSH_AUTOSUGGEST_USE_ASYNC=1
" \
atload"_zsh_autosuggest_start"
zinit light zsh-users/zsh-autosuggestions
# syntax highlighting
zinit ice wait lucid \
atinit"ZINIT[COMPINIT_OPTS]=-C; zicompinit; zicdreplay"
zinit light zsh-users/zsh-syntax-highlighting
# 1Password plugins: https://developer.1password.com/docs/cli/shell-plugins/
zinit ice wait lucid \
id-as"op-plugins" \
# NOTE: this needs to happen *after* generating the completions above, otherwise it'll ask for touch ID to do very
# simple tasks...
zinit ice wait"1" lucid \
id-as"_local/op-auth" \
has"op" \
if"[[ -f ~/.config/op/plugins.sh ]]"
if"[[ -f ~/.config/op/plugins.sh ]]" \
nocompile
zinit snippet ~/.config/op/plugins.sh
# oh-my-zsh leftovers
# https://github.com/ohmyzsh/ohmyzsh/tree/master/lib
zinit snippet OMZ::lib/clipboard.zsh
zinit snippet OMZ::lib/termsupport.zsh
# iTerm2 integration
# shellcheck disable=SC2016
zinit ice lucid \
zinit ice lucid depth"1" \
if'[[ "$TERM_PROGRAM" = "iTerm.app" ]]' \
pick"shell_integration/zsh" \
sbin"utilities/*"
atload'path=("$(pwd)/utilities" $path)' \
src"shell_integration/zsh" \
nocompile
zinit light gnachman/iTerm2-shell-integration
# starship prompt
zinit ice from"gh-r" as"command" \
atclone"
./starship init zsh --print-full-init > init.zsh
./starship completions zsh > _starship
./starship init zsh --print-full-init > init.zsh
zcompile init.zsh
" \
atpull"%atclone" \
src"init.zsh"