mirror of
https://github.com/jakejarvis/dotfiles.git
synced 2025-09-15 23:15:30 -04:00
🚀 massive overhaul using zinit & starship
This commit is contained in:
111
zsh/custom/aliases.zsh
Normal file
111
zsh/custom/aliases.zsh
Normal file
@@ -0,0 +1,111 @@
|
||||
# allow sudo-able aliases
|
||||
alias sudo="sudo "
|
||||
|
||||
# colorful ls
|
||||
alias ls="ls -G --color=auto"
|
||||
alias ll="ls -lah"
|
||||
alias la="ls -a"
|
||||
alias l="ll"
|
||||
|
||||
# easier dotfile tinkering
|
||||
alias shreload="exec \$SHELL"
|
||||
|
||||
# git
|
||||
alias g="git"
|
||||
alias gc="git commit -m" # + commit message
|
||||
alias gca="git add . && git commit -m" # + commit message
|
||||
alias gs="git status -sb"
|
||||
alias gl="git log --pretty=short"
|
||||
alias gd="git diff"
|
||||
alias gds="git diff --staged"
|
||||
alias gpom="git push origin main"
|
||||
alias glom="git pull origin main"
|
||||
alias gpo="git push origin" # + branch name
|
||||
alias glo="git pull origin" # + branch name
|
||||
alias gb="git checkout" # + existing branch name
|
||||
alias gbn="git checkout -b" # + new branch name
|
||||
alias grm="git rebase -i origin/main"
|
||||
alias gsub="git submodule update --recursive --remote"
|
||||
alias gundo="git reset --soft HEAD~1"
|
||||
alias gres="git reset"
|
||||
alias github="gh repo view --web"
|
||||
alias gist="gh gist create --web"
|
||||
|
||||
# docker
|
||||
alias dps="docker ps -a"
|
||||
dbar() {
|
||||
# build and run:
|
||||
# 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 {}
|
||||
}
|
||||
dsh() {
|
||||
docker exec -it "$1" /bin/sh
|
||||
}
|
||||
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"
|
||||
|
||||
# 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 shell "$1"
|
||||
}
|
||||
alias mpls="multipass list"
|
||||
alias mpsh="multipass shell"
|
||||
alias mpk="multipass stop"
|
||||
alias mpd="multipass delete"
|
||||
|
||||
# Node/NPM/Yarn
|
||||
alias npr="npm run"
|
||||
alias fresh_npm="rm -rf node_modules package-lock.json && npm install"
|
||||
alias fresh_yarn="rm -rf node_modules yarn.lock && yarn install"
|
||||
|
||||
# Hugo
|
||||
# install from source
|
||||
make_hugo() {
|
||||
# parentheses lets us cd to Hugo path without changing our current location
|
||||
(
|
||||
cd "$GOPATH/src/github.com/gohugoio/hugo" \
|
||||
&& bash -c "$GOPATH/bin/hugo env" \
|
||||
&& git checkout master \
|
||||
&& mage uninstall \
|
||||
&& git pull origin master \
|
||||
&& git reset --hard HEAD \
|
||||
&& mage -v hugo \
|
||||
&& HUGO_BUILD_TAGS=extended mage -v install \
|
||||
&& bash -c "$GOPATH/bin/hugo env"
|
||||
)
|
||||
}
|
||||
# install from brew
|
||||
alias hugo_brew="brew upgrade hugo --fetch-HEAD --build-from-source"
|
||||
# run `hugo config` first to make sure we're in a Hugo directory:
|
||||
alias hugo_clean="hugo config 1>/dev/null && rm -rf public/ resources/ build/"
|
||||
|
||||
# an original creation, see https://github.com/jakejarvis/simpip
|
||||
alias ipv4="curl -4 simpip.com --max-time 1 --proto-default https --silent"
|
||||
alias ipv6="curl -6 simpip.com --max-time 1 --proto-default https --silent"
|
||||
alias ip="ipv4; ipv6"
|
||||
alias ip-local="ipconfig getifaddr en0"
|
||||
alias ips="ip; ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'"
|
||||
|
||||
# keys
|
||||
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.'"
|
||||
|
||||
# tailscale: https://tailscale.com/kb/1080/cli/?tab=macos
|
||||
alias tailscale="/Applications/Tailscale.app/Contents/MacOS/Tailscale"
|
||||
alias tscl="tailscale"
|
||||
|
||||
# youtube-dl
|
||||
alias youtube-dl="yt-dlp" # fork: https://github.com/yt-dlp/yt-dlp
|
||||
alias ytdl="youtube-dl -f bestvideo+bestaudio"
|
||||
alias ytmp3="youtube-dl -f bestaudio -x --audio-format mp3 --audio-quality 320K"
|
||||
|
||||
# misc.
|
||||
alias screenfetch="neofetch"
|
||||
alias weather="curl 'https://wttr.in/?format=v2'"
|
53
zsh/custom/common.zsh
Normal file
53
zsh/custom/common.zsh
Normal file
@@ -0,0 +1,53 @@
|
||||
autoload -U colors && colors
|
||||
|
||||
autoload -Uz url-quote-magic
|
||||
zle -N self-insert url-quote-magic
|
||||
|
||||
autoload -Uz select-word-style
|
||||
select-word-style shell
|
||||
|
||||
# ---
|
||||
|
||||
setopt notify
|
||||
setopt complete_in_word
|
||||
setopt always_to_end
|
||||
setopt extended_history
|
||||
setopt hist_expire_dups_first
|
||||
# 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 correct
|
||||
unsetopt correct_all
|
||||
|
||||
# ---
|
||||
|
||||
bindkey -e
|
||||
bindkey "^[^[[D" backward-word
|
||||
bindkey "^[^[[C" forward-word
|
||||
|
||||
# ---
|
||||
|
||||
export LC_ALL="${LC_ALL:-en_US.UTF-8}"
|
||||
export LANG="${LANG:-en_US.UTF-8}"
|
||||
|
||||
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 HISTFILE=~/.zsh_history
|
||||
export HISTSIZE=10000
|
||||
export SAVEHIST=10000
|
||||
|
||||
export EDITOR="nano" # don't judge me
|
||||
export VISUAL="code"
|
||||
|
||||
# https://github.com/ohmyzsh/ohmyzsh/blob/master/lib/theme-and-appearance.zsh#L5
|
||||
# export LS_COLORS="Gxfxcxdxbxegedabagacad"
|
9
zsh/custom/env.zsh
Normal file
9
zsh/custom/env.zsh
Normal file
@@ -0,0 +1,9 @@
|
||||
export HOMEBREW_NO_ANALYTICS=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
|
||||
export AZURE_CORE_COLLECT_TELEMETRY=0
|
||||
export CHECKPOINT_DISABLE=1
|
84
zsh/custom/functions.zsh
Normal file
84
zsh/custom/functions.zsh
Normal file
@@ -0,0 +1,84 @@
|
||||
# Make a new directory and `cd` right into it (this seems like a no-brainer)
|
||||
mkcd() {
|
||||
mkdir -p -- "$1" &&
|
||||
cd -P -- "$1" || return
|
||||
}
|
||||
|
||||
# Start an HTTP server from a directory, optionally specifying the port
|
||||
serve() {
|
||||
local port="${1:-8090}"
|
||||
sleep 1 && open "http://localhost:${port}/" &
|
||||
# Set the default Content-Type to `text/plain` instead of `application/octet-stream`
|
||||
# And serve everything as UTF-8 (although not technically correct, this doesn't break anything for binary files)
|
||||
python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port"
|
||||
}
|
||||
|
||||
# Extract a compressed archive without worrying about which tool to use
|
||||
extract() {
|
||||
if [[ -f "$1" ]]; then
|
||||
case "$1" in
|
||||
*.tar.bz2)
|
||||
tar xjf "$1"
|
||||
;;
|
||||
*.tar.gz)
|
||||
tar xzf "$1"
|
||||
;;
|
||||
*.bz2)
|
||||
bunzip2 "$1"
|
||||
;;
|
||||
*.rar)
|
||||
unrar x "$1"
|
||||
;;
|
||||
*.gz)
|
||||
gunzip "$1"
|
||||
;;
|
||||
*.tar)
|
||||
tar xf "$1"
|
||||
;;
|
||||
*.tbz2)
|
||||
tar xjf "$1"
|
||||
;;
|
||||
*.tgz)
|
||||
tar xzf "$1"
|
||||
;;
|
||||
*.zip)
|
||||
unzip "$1"
|
||||
;;
|
||||
*.Z)
|
||||
uncompress "$1"
|
||||
;;
|
||||
*.7z)
|
||||
7z x "$1"
|
||||
;;
|
||||
*)
|
||||
echo "'$1' cannot be extracted via extract()"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo "'$1' is not a valid file"
|
||||
fi
|
||||
}
|
||||
|
||||
# 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
|
||||
gitio() {
|
||||
local PARAMS RESPONSE
|
||||
PARAMS="-F \"url=$1\""
|
||||
if [[ -n "$2" ]]; then
|
||||
PARAMS="$PARAMS -F \"code=$2\""
|
||||
fi
|
||||
RESPONSE=$(eval "curl -i https://git.io $PARAMS 2>&1" | grep "Location: ")
|
||||
echo "${RESPONSE//Location: /}"
|
||||
}
|
||||
|
||||
# Push a local SSH public key to another machine
|
||||
# https://github.com/rtomayko/dotfiles/blob/rtomayko/.bashrc
|
||||
push_ssh_cert() {
|
||||
local _host
|
||||
[[ -f ~/.ssh/id_ed25519.pub ]] || ssh-keygen -t ed25519
|
||||
for _host in "$@"; do
|
||||
echo "$_host"
|
||||
ssh "$_host" "\cat >> ~/.ssh/authorized_keys" < ~/.ssh/id_ed25519.pub
|
||||
done
|
||||
}
|
96
zsh/custom/macos.zsh
Normal file
96
zsh/custom/macos.zsh
Normal file
@@ -0,0 +1,96 @@
|
||||
# all of this is only for macOS
|
||||
if [[ ! "$(uname)" = "Darwin" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# export BROWSER="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"
|
||||
export BROWSER="/Applications/Firefox.app/Contents/MacOS/firefox"
|
||||
|
||||
# Rosetta hacks for M1
|
||||
alias intel="arch -x86_64 /bin/zsh"
|
||||
alias arm="arch -arm64 zsh"
|
||||
|
||||
# check & install updates for:
|
||||
# - brew
|
||||
# - node/npm
|
||||
# - ruby/gems
|
||||
# - pip
|
||||
# - app store
|
||||
# - macos
|
||||
# - zinit
|
||||
system_update() {
|
||||
NC="\033[0m"
|
||||
YELLOW="\033[0;33m"
|
||||
|
||||
echo -e "${YELLOW}Updating Homebrew formulae and casks...${NC}"
|
||||
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
|
||||
|
||||
echo -e "${YELLOW}Updating global NPM/Yarn packages...${NC}"
|
||||
volta fetch node@latest
|
||||
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
|
||||
|
||||
echo -e "${YELLOW}Updating Ruby and gems...${NC}"
|
||||
CONFIGURE_OPTS="$RUBY_CONFIGURE_OPTS" \
|
||||
rbenv install --skip-existing "$(rbenv install -l | grep -v - | tail -1)" && \
|
||||
rbenv global "$(rbenv install -l | grep -v - | tail -1)"
|
||||
gem install bundler foreman
|
||||
gem update
|
||||
gem cleanup
|
||||
rbenv rehash
|
||||
|
||||
# https://stackoverflow.com/a/3452888
|
||||
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
|
||||
|
||||
echo -e "${YELLOW}Checking for App Store updates...${NC}"
|
||||
mas outdated
|
||||
|
||||
echo -e "${YELLOW}Checking for macOS system updates...${NC}"
|
||||
softwareupdate --list
|
||||
|
||||
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 forcetrash="sudo rm -rf ~/.Trash /Volumes/*/.Trashes"
|
||||
alias unq="sudo xattr -rd com.apple.quarantine"
|
||||
alias verify_sign="codesign --verify --deep --verbose"
|
||||
|
||||
alias gpu="system_profiler SPDisplaysDataType"
|
||||
alias cpu="sysctl -n machdep.cpu.brand_string"
|
||||
|
||||
alias ripfinder="killall Finder"
|
||||
alias ripdock="killall Dock"
|
||||
alias ripmenu="killall SystemUIServer NotificationCenter"
|
||||
|
||||
# open current directory in Finder
|
||||
alias finder="open -a Finder ."
|
||||
|
||||
alias dns-clear="networksetup -setdnsservers Wi-Fi"
|
||||
alias dns-check="networksetup -getdnsservers Wi-Fi"
|
||||
alias dns-set="networksetup -setdnsservers Wi-Fi "
|
||||
alias dns-set-cloudflare="dns-set 1.1.1.1 1.0.0.1"
|
||||
alias dns-set-google="dns-set 8.8.8.8 8.8.4.4"
|
||||
alias flush="sudo killall -HUP mDNSResponder; sudo killall mDNSResponderHelper; sudo dscacheutil -flushcache"
|
||||
|
||||
# uncomment to use VS Code insiders build
|
||||
# alias code="code-insiders"
|
||||
alias vs="code ."
|
||||
|
||||
# Xcode simulators
|
||||
alias ios="open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app"
|
||||
alias watchos="open /Applications/Xcode.app/Contents/Developer/Applications/Simulator\ \(Watch\).app"
|
||||
|
||||
alias firefox="/Applications/Firefox.app/Contents/MacOS/firefox-bin"
|
||||
alias ff="firefox"
|
49
zsh/custom/path.zsh
Normal file
49
zsh/custom/path.zsh
Normal file
@@ -0,0 +1,49 @@
|
||||
# a lot of this file only applies to macOS
|
||||
if [[ "$(uname)" = "Darwin" ]]; then
|
||||
# set PATH, MANPATH, etc., for Homebrew
|
||||
eval "$(/opt/homebrew/bin/brew shellenv)"
|
||||
|
||||
# remap macOS core utils to GNU equivalents (from coreutils, findutils, gnu-*, etc.):
|
||||
# https://gist.github.com/skyzyx/3438280b18e4f7c490db8a2a2ca0b9da?permalink_comment_id=3049694#gistcomment-3049694
|
||||
for gbin in "$(brew --prefix)"/opt/*/libexec/gnubin; do
|
||||
export PATH="$gbin:$PATH"
|
||||
done
|
||||
# Ensure `man` refers to the new binaries:
|
||||
for gman in "$(brew --prefix)"/opt/*/libexec/gnuman; do
|
||||
export MANPATH="$gman:$MANPATH"
|
||||
done
|
||||
unset gbin gman
|
||||
|
||||
# OpenJDK
|
||||
export PATH="$HOMEBREW_PREFIX/opt/openjdk/bin:$PATH"
|
||||
|
||||
# metasploit
|
||||
export PATH="/opt/metasploit-framework/bin:$PATH"
|
||||
|
||||
# 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)"
|
||||
fi
|
||||
|
||||
# go
|
||||
export GOPATH="$HOME/golang"
|
||||
export PATH="$GOPATH/bin:$PATH"
|
||||
|
||||
# rbenv
|
||||
if command -v rbenv 1>/dev/null 2>&1; then
|
||||
eval "$(rbenv init -)"
|
||||
fi
|
||||
|
||||
# rust/cargo
|
||||
export PATH="$HOME/.cargo/bin:$PATH"
|
||||
|
||||
# pyenv
|
||||
export PYENV_ROOT="$HOME/.pyenv"
|
||||
export PATH="$PYENV_ROOT/bin:$PATH"
|
||||
if command -v pyenv 1>/dev/null 2>&1; then
|
||||
eval "$(pyenv init -)"
|
||||
fi
|
||||
|
||||
# volta
|
||||
export VOLTA_HOME="$HOME/.volta"
|
||||
export PATH="$VOLTA_HOME/bin:$PATH"
|
203
zsh/custom/plugins.zsh
Normal file
203
zsh/custom/plugins.zsh
Normal file
@@ -0,0 +1,203 @@
|
||||
# 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"
|
||||
fi
|
||||
|
||||
# initialize zinit
|
||||
# shellcheck disable=SC1091
|
||||
source "$ZINIT_HOME/zinit.zsh"
|
||||
|
||||
# ensure compinit recognizes zinit's changes
|
||||
autoload -Uz _zinit
|
||||
# shellcheck disable=SC2154
|
||||
(( ${+_comps} )) && _comps[zinit]=_zinit
|
||||
|
||||
# various zinit add-ons
|
||||
zinit light zdharma-continuum/zinit-annex-patch-dl
|
||||
|
||||
# async support
|
||||
zinit ice wait lucid \
|
||||
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" \
|
||||
mv"bin/exa* -> exa" \
|
||||
atclone"
|
||||
mv -vf completions/exa.zsh _exa
|
||||
mv -vf man/exa.1 ${ZINIT[MAN_DIR]}/man1
|
||||
mv -vf man/exa_colors.5 ${ZINIT[MAN_DIR]}/man5
|
||||
" \
|
||||
atpull"%atclone" \
|
||||
atload"
|
||||
alias ls='exa --color=auto -GF --icons --group-directories-first'
|
||||
alias ll='exa --color=auto -1laF --git --icons --group-directories-first --ignore-glob=\".DS_Store*|~*\"'
|
||||
alias lt='ll -T -L=2'
|
||||
"
|
||||
zinit light ogham/exa
|
||||
|
||||
# grab bat (better cat) binary
|
||||
zinit ice from"gh-r" as"command" \
|
||||
mv"bat-*/bat -> bat" \
|
||||
atclone"
|
||||
mv -vf bat-*/autocomplete/bat.zsh _bat
|
||||
mv -vf bat-*/bat.1 ${ZINIT[MAN_DIR]}/man1
|
||||
" \
|
||||
atpull"%atclone" \
|
||||
atload"alias cat='bat --paging=never --color=auto --style=\"numbers,changes\" --theme=\"Dracula\"'"
|
||||
zinit light sharkdp/bat
|
||||
|
||||
# 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" \
|
||||
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 --theme=Dracula"
|
||||
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"
|
||||
'
|
||||
zinit light sharkdp/fd
|
||||
|
||||
# grab fzf binary from release & other files from source
|
||||
zinit ice from"gh-r" as"command" \
|
||||
dl"https://raw.githubusercontent.com/junegunn/fzf/master/shell/key-bindings.zsh -> key-bindings.zsh" \
|
||||
dl"https://raw.githubusercontent.com/junegunn/fzf/master/shell/completion.zsh -> _fzf" \
|
||||
dl"https://raw.githubusercontent.com/junegunn/fzf/master/man/man1/fzf.1 -> ${ZINIT[MAN_DIR]}/man1/fzf.1" \
|
||||
dl"https://raw.githubusercontent.com/junegunn/fzf/master/man/man1/fzf-tmux.1 -> ${ZINIT[MAN_DIR]}/man1/fzf-tmux.1" \
|
||||
src"key-bindings.zsh"
|
||||
zinit light junegunn/fzf
|
||||
|
||||
# all the colors
|
||||
# https://github.com/sharkdp/vivid/tree/master/themes
|
||||
# shellcheck disable=SC2016
|
||||
zinit ice from"gh-r" as"command" \
|
||||
mv"vivid-*/vivid -> vivid" \
|
||||
atload'export LS_COLORS="$(vivid generate snazzy)"'
|
||||
zinit load sharkdp/vivid
|
||||
|
||||
# direnv
|
||||
zinit ice from"gh-r" as"command" \
|
||||
mv"direnv* -> direnv" \
|
||||
atclone"./direnv hook zsh > zhook.zsh" \
|
||||
atpull"%atclone" \
|
||||
src"zhook.zsh"
|
||||
zinit light direnv/direnv
|
||||
|
||||
# history substring searching
|
||||
# only bind these keys once they're ready
|
||||
bindkey -r "^[[A"
|
||||
bindkey -r "^[[B"
|
||||
zinit ice wait lucid \
|
||||
atload"
|
||||
zmodload zsh/terminfo
|
||||
bindkey '^[[A' history-substring-search-up
|
||||
bindkey '^[[B' history-substring-search-down
|
||||
"
|
||||
zinit light zsh-users/zsh-history-substring-search
|
||||
|
||||
# tab completions via fzf
|
||||
# TODO: fix git-* completions, apparently there's some conflict with brew's git
|
||||
# https://github.com/Aloxaf/fzf-tab/wiki/Preview#git
|
||||
zinit ice wait lucid \
|
||||
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::complete:rm:*:globbed-files' ignored-patterns
|
||||
zstyle ':fzf-tab:*' fzf-command fzf
|
||||
zstyle ':fzf-tab:*' fzf-bindings \
|
||||
'tab:accept' \
|
||||
'ctrl-y:preview-page-up' \
|
||||
'ctrl-v:preview-page-down' \
|
||||
'ctrl-e:execute-silent(${VISUAL:-code} \${realpath:-\$word} >/dev/null 2>&1)' \
|
||||
'ctrl-w:execute(${EDITOR:-nano} \${realpath:-\$word} >/dev/tty </dev/tty)+refresh-preview'
|
||||
zstyle ':fzf-tab:*' fzf-min-height 15
|
||||
zstyle ':fzf-tab:complete:git-(add|diff|restore):*' fzf-preview \
|
||||
'git --no-pager diff --color=always --no-ext-diff \${realpath:-\$word} | delta'
|
||||
zstyle ':fzf-tab:complete:git-log:*' fzf-preview \
|
||||
'git --no-pager log --color=always --format=oneline --abbrev-commit --follow \${realpath:-\$word}'
|
||||
zstyle ':fzf-tab:complete:man:*' fzf-preview \
|
||||
'man \$word'
|
||||
zstyle ':fzf-tab:complete:brew-(install|uninstall|search|info):*-argument-rest' fzf-preview \
|
||||
'brew info \$word'
|
||||
zstyle ':fzf-tab:complete:(-command-|-parameter-|-brace-parameter-|export|unset|expand):*' fzf-preview \
|
||||
'echo \${(P)word}'
|
||||
zstyle ':fzf-tab:complete:*:options' fzf-preview
|
||||
zstyle ':fzf-tab:complete:*:options' fzf-flags '--no-preview'
|
||||
zstyle ':fzf-tab:complete:*:argument-1' fzf-preview
|
||||
zstyle ':fzf-tab:complete:*:argument-1' fzf-flags '--no-preview'
|
||||
zstyle ':fzf-tab:complete:*:*' fzf-preview \
|
||||
'($FZF_PREVIEW_FILE_COMMAND \$realpath || $FZF_PREVIEW_DIR_COMMAND \$realpath) 2>/dev/null'
|
||||
"
|
||||
zinit light Aloxaf/fzf-tab
|
||||
|
||||
# autosuggestions, trigger precmd hook upon load
|
||||
zinit ice wait lucid \
|
||||
atload"_zsh_autosuggest_start"
|
||||
zinit light zsh-users/zsh-autosuggestions
|
||||
|
||||
# additional completions
|
||||
zinit ice wait lucid blockf as"completion" \
|
||||
atpull"zinit creinstall -q ."
|
||||
zinit light zsh-users/zsh-completions
|
||||
|
||||
# syntax highlighting
|
||||
zinit ice wait lucid \
|
||||
atinit"ZINIT[COMPINIT_OPTS]=-C; zicompinit; zicdreplay"
|
||||
zinit light zsh-users/zsh-syntax-highlighting
|
||||
|
||||
# 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
|
||||
zinit ice lucid \
|
||||
if'[[ "$TERM_PROGRAM" = "iTerm.app" ]]' \
|
||||
pick"shell_integration/zsh" \
|
||||
sbin"utilities/*"
|
||||
zinit light gnachman/iTerm2-shell-integration
|
||||
|
||||
# 1Password plugins: https://developer.1password.com/docs/cli/shell-plugins/
|
||||
zinit ice \
|
||||
if"command -v op &>/dev/null" \
|
||||
atclone"op completion zsh > _op || true"
|
||||
zinit snippet ~/.config/op/plugins.sh
|
||||
|
||||
# starship prompt
|
||||
zinit ice from"gh-r" as"command" \
|
||||
atclone"
|
||||
./starship init zsh > init.zsh
|
||||
./starship completions zsh > _starship
|
||||
" \
|
||||
atpull"%atclone" \
|
||||
src"init.zsh"
|
||||
zinit light starship/starship
|
Reference in New Issue
Block a user