Last active
May 8, 2023 20:44
-
-
Save Arzte/6437ab8aa1fb0361fc1d122705a0e99d to your computer and use it in GitHub Desktop.
My zshrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Alacritty sets this to Alacritty by default, | |
# set to 256 so colors work properly | |
export TERM="xterm-256color" | |
# Vim mode | |
## VIM is a great editor, let's use it's interface everywhere | |
bindkey -v | |
# Options | |
setopt cdable_vars # Like AUTO_CD, but for named directories | |
setopt bang_hist # Treat The '!' Character Specially During Expansion. | |
setopt multios # Perform implicit tees or cats when multiple redirections are attempted. | |
setopt interactive_comments # Allow comments even in interactive shells (especially for Muness). | |
setopt pushd_ignore_dups # Don't push multiple copies of the same directory onto the directory stack. | |
setopt auto_cd # Use cd by typing directory name if it's not a command. | |
setopt no_beep # Don't beep on error. | |
setopt auto_list # Automatically list choices on ambiguous completion. | |
setopt auto_pushd # Make cd push the old directory onto the directory stack. | |
setopt pushdminus # Swapped the meaning of cd +1 and cd -1; we want them to mean the opposite of what they mean. | |
setopt promptsubst # Enables the substitution of parameters inside the prompt each time the prompt is drawn. | |
setopt hist_expire_dups_first # Expire A Duplicate Event First When Trimming History. | |
setopt hist_ignore_dups # Do Not Record An Event That Was Just Recorded Again. | |
setopt hist_reduce_blanks # Remove superfluous blanks from history items. | |
setopt hist_find_no_dups # Do Not Display A Previously Found Event. | |
setopt hist_ignore_space # Do Not Record An Event Starting With A Space. | |
setopt hist_save_no_dups # Do Not Write A Duplicate Event To The History File. | |
setopt hist_verify # Do Not Execute Immediately Upon History Expansion. | |
setopt append_history # Allow multiple terminal sessions to all append to one zsh command history. | |
setopt extended_history # Show Timestamp In History. | |
setopt inc_append_history # Write To The History File Immediately, Not When The Shell Exits. | |
setopt share_history # Share history between different instances of the shell | |
## History environment variables | |
HISTFILE=${HOME}/.zsh_history | |
HISTSIZE=120000 # Larger than $SAVEHIST for HIST_EXPIRE_DUPS_FIRST to work | |
SAVEHIST=100000 | |
## Completion Options | |
# Fuzzy Matching | |
zstyle ':completion:*' completer _complete _match _approximate | |
zstyle ':completion:*:match:*' original only | |
zstyle -e ':completion:*:approximate:*' max-errors 'reply=($((($#PREFIX+$#SUFFIX)/3>7?7:($#PREFIX+$#SUFFIX)/3))numeric)' | |
# Pretty Completions | |
zstyle ':completion:*:matches' group 'yes' | |
zstyle ':completion:*:options' description 'yes' | |
zstyle ':completion:*:options' auto-description '%d' | |
zstyle ':completion:*:corrections' format ' %F{green}-- %d (errors: %e) --%f' | |
zstyle ':completion:*:descriptions' format ' %F{yellow}-- %d --%f' | |
zstyle ':completion:*:messages' format ' %F{purple} -- %d --%f' | |
zstyle ':completion:*:warnings' format ' %F{red}-- no matches found --%f' | |
zstyle ':completion:*:default' list-prompt '%S%M matches%s' | |
zstyle ':completion:*' format ' %F{yellow}-- %d --%f' | |
zstyle ':completion:*' group-name '' | |
zstyle ':completion:*' verbose yes | |
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' | |
zstyle ':completion:*:functions' ignored-patterns '(_*|pre(cmd|exec))' | |
zstyle ':completion:*' use-cache true | |
zstyle ':completion:*' rehash true | |
# Menu Based Completions | |
zstyle ':completion:*' menu select | |
# Colour Completion on Some Things | |
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} | |
# disable sort when completing `git checkout` | |
zstyle ':completion:*:git-checkout:*' sort false | |
# preview directory's content with exa when completing cd | |
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'exa -1 --color=always $realpath' | |
# Locale | |
export LC_ALL=en_US.UTF-8 | |
export LANG=en_US.UTF-8 | |
export LANGUAGE=en_US.UTF-8 | |
upgrade() { | |
# Update Zi first, otherwise it runs the risk of getting suspended with a large shell output | |
zi self-update | |
# Update brew's internal list, then upgrade all outdated packages | |
(brew update && brew upgrade && brew upgrade --cask $(brew outdated --cask --greedy | grep -Eiv "firefox|google-chrome")) | |
# Update Zi plugins, AFTER brew, as some plugins rely on brew packages | |
zi update --parallel | |
# Upgrade all global yarn packages | |
yarn global upgrade | |
# Currently broken, disabled until I have the time to figure out why it isn't working (and care about python packages again) | |
# pipupgrade -y # Upgrade all pip packages | |
# update our rust tool-chains to the latest and greatest version of rust | |
rustup update | |
# Update to new versions of cargo installed programs | |
cargo install-update -a | |
# Disabled as it's a time hog with little benefit if I'm not spending a lot of time developing rust stuff | |
# cleanup cargo's cache, and recompress git repos | |
# cargo cache -e | |
# Remove old/uninstalled versions of the rust toolchain in my rust target directories | |
(cd $HOME/git && cargo sweep -r --installed) | |
# This waits for all the commands to finish before exiting | |
wait | |
} | |
# Alias's | |
# Use the cool rust ls, vs the dinky UNIX one | |
alias ls="exa --all --git --header -l" | |
#alias ls="ls -al" | |
alias cat="bat" | |
alias dust="dust -r" | |
alias du="dust" | |
alias lzd="lazydocker" | |
alias find="fd" | |
alias gdiff="git diff --diff-algorithm=patience --ignore-space-change" | |
# Set default editor to nvim | |
export EDITOR="/usr/local/bin/nvim" | |
# Use ripgrep over fzf's default for SPEED | |
export FZF_DEFAULT_COMMAND='fd --color=always --type f --hidden --follow --exclude .git' | |
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" | |
export FZF_DEFAULT_OPTS="--ansi" | |
# Allow gpg to work because it won't | |
export GPG_TTY=$(tty) | |
# Tells hacker quotes to get with the program | |
ZSH_HACKER_QUOTES_ENABLE_WHEN_INTERACTIVE=true | |
export PATH="/Users/iris/.local/bin:$PATH" | |
export PATH="/usr/local/sbin:$PATH" | |
# Added by zi Installer | |
if [[ ! -f $HOME/.zi/bin/zi.zsh ]]; then | |
print -P "%F{33}▓▒░ %F{160}Installing (%F{33}z-shell/zi%F{160})…%f" | |
command mkdir -p "$HOME/.zi" && command chmod g-rwX "$HOME/.zi" | |
command git clone -q --depth=1 --branch "main" https://github.com/z-shell/zi "$HOME/.zi/bin" && \ | |
print -P "%F{33}▓▒░ %F{34}Installation successful.%f%b" || \ | |
print -P "%F{160}▓▒░ The clone has failed.%f%b" | |
fi | |
source "$HOME/.zi/bin/zi.zsh" | |
autoload -Uz _zi | |
(( ${+_comps} )) && _comps[zi]=_zi | |
# https://z.digitalclouds.dev/ecosystem/annexes | |
zi light-mode for \ | |
z-shell/z-a-meta-plugins \ | |
@annexes \ | |
skip'F-Sy-H' @z-shell \ | |
oz/safe-paste | |
zi wait lucid for \ | |
z-shell/zzcomplete \ | |
@ext-git \ | |
@zsh-users+fast \ | |
skip'tig' @console-tools \ | |
@fuzzy \ | |
as'program' from'gh-r' sbin'**/delta -> delta' dandavison/delta | |
#py-utils # I prefer brew's pyenv at the moment | |
zi wait lucid pack for \ | |
brew-completions \ | |
system-completions | |
# Snippets | |
zi wait lucid as'completion' blockf for \ | |
has'cargo' https://github.com/rust-lang/cargo/blob/master/src/etc/_cargo \ | |
has'rg' https://github.com/BurntSushi/ripgrep/blob/master/complete/_rg \ | |
has'tldr' mv'zsh_tealdeer -> _tldr' https://github.com/dbrgn/tealdeer/blob/main/completion/zsh_tealdeer \ | |
has'alacritty' https://github.com/alacritty/alacritty/blob/master/extra/completions/_alacritty \ | |
OMZ::plugins/rust/_rustc \ | |
OMZ::plugins/macos \ | |
OMZ::plugins/fd/_fd | |
# Use fzf for completion | |
zi ice lucid wait has'fzf' | |
zi light Aloxaf/fzf-tab | |
# Generated Completions for ferium | |
zi ice lucid wait as'completion' blockf has'ferium' | |
zi snippet "${HOME}/.ferium.zsh" | |
# examples here -> https://z.digitalclouds.dev/docs/gallery/collection | |
zicompinit # <- https://z.digitalclouds.dev/docs/guides/commands | |
### Binaries run after zi plugins | |
# neofetch # Disabled cause it's slow | |
nerdfetch | |
# hacker quotes | |
zi light oldratlee/hacker-quotes | |
# If we have network connectivity get the current weather for Indianapolis using | |
# wttr.in's "Data-rich output format" (v2) specifically the Nerd Font day version | |
#if ping -q -t 1 -c 1 169.150.219.147 > /dev/null; then | |
# curl "v2d.wttr.in/Indianapolis?u" | |
#fi | |
# Starship Prompt | |
## Currently Broken | |
## zi ice as"command" from"gh-r" \ | |
## atclone"./starship init zsh > init.zsh; ./starship completions zsh > _starship" \ | |
## atpull"%atclone" src"init.zsh" | |
## zi light starship/starship | |
source <(/usr/local/bin/starship init zsh --print-full-init) | |
# NVM stuffz | |
export NVM_DIR="$HOME/.nvm" | |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm | |
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion | |
# place this after nvm initialization! | |
autoload -U add-zsh-hook | |
load-nvmrc() { | |
local node_version="$(nvm version)" | |
local nvmrc_path="$(nvm_find_nvmrc)" | |
if [ -n "$nvmrc_path" ]; then | |
local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")") | |
if [ "$nvmrc_node_version" = "N/A" ]; then | |
nvm install | |
elif [ "$nvmrc_node_version" != "$node_version" ]; then | |
nvm use | |
fi | |
elif [ "$node_version" != "$(nvm version default)" ]; then | |
echo "Reverting to nvm default version" | |
nvm use default | |
fi | |
} | |
add-zsh-hook chpwd load-nvmrc | |
load-nvmrc | |
## LG WebOS Developer stuffz (I'm not a developer but some apps need it for reasons :tm:) | |
# Setting the LG_WEBOS_TV_SDK_HOME variable to the parent directory of CLI | |
export LG_WEBOS_TV_SDK_HOME="$HOME/Downloads/webos" | |
if [ -d "$LG_WEBOS_TV_SDK_HOME/CLI/bin" ]; then | |
# Setting the WEBOS_CLI_TV variable to the bin directory of CLI | |
export WEBOS_CLI_TV="$LG_WEBOS_TV_SDK_HOME/CLI/bin" | |
# Adding the bin directory of CLI to the PATH variable | |
export PATH="$PATH:$WEBOS_CLI_TV" | |
fi | |
# Pyenv shell stuff (Required with zinit not managing my pyenv install | |
export PYENV_ROOT="$HOME/.pyenv" | |
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH" | |
eval "$(pyenv init -)" | |
## Virtualenv stuff, this allows pyenv to manage my virtualenv so I never have to touch it outside of pyenv | |
eval "$(pyenv virtualenv-init -)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment