Last active
November 30, 2025 23:56
-
-
Save Menchen/13b931ed9c0175c13c840b7e5513af93 to your computer and use it in GitHub Desktop.
Zsh config
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
| #!/usr/bin/env zsh | |
| # Use the following command to initialize the first time | |
| # curl "https://gist.githubusercontent.com/Menchen/13b931ed9c0175c13c840b7e5513af93/raw/.zshconf.zsh" -s -o ~/.zshconf.zsh && zsh -d -f -i -l -c "source ~/.zshconf.zsh" && exec zsh -i -l | |
| if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then | |
| source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" | |
| fi | |
| # ZDOTDIR="$HOME/.zshconf.zsh zsh" | |
| # Auto zinit installer | |
| if [[ ! -f $HOME/.zinit/bin/zinit.zsh ]]; then | |
| if [[ -n "$commands[git]" ]]; then | |
| echo "Git is required for Zinit installation" | |
| exit | |
| fi | |
| ZSHRC="${ZSHRC:-${ZDOTDIR:-${HOME}}/.zshrc}" | |
| print -P "%F{33}▓▒░ %F{220}Installing %F{33}DHARMA%F{220} Initiative Plugin Manager (%F{33}zdharma/zinit%F{220})…%f" | |
| command mkdir -p "$HOME/.zinit" && command chmod g-rwX "$HOME/.zinit" | |
| command git clone https://github.com/zdharma-continuum/zinit "$HOME/.zinit/bin" && \ | |
| print -P "%F{33}▓▒░ %F{34}Installation successful.%f%b" || \ | |
| print -P "%F{160}▓▒░ The clone has failed.%f%b" | |
| if grep -E '\.zshconf\.zsh' "${ZSHRC}" > /dev/null 2>&1; then | |
| echo_warning "${ZSHRC} already contains bootstrap to .zshconf.zsh commands. Not making any changes." | |
| else | |
| echo "source ~/.zshconf.zsh" >> $HOME/.zshrc | |
| fi | |
| zinit wait'!' lucid atinit'echo "All wait plugins loaded!"' | |
| zinit wait'!' lucid atinit'exec zsh -li' | |
| fi | |
| # if [[ -f $HOME/.zinit/module/Src/zdharma_continuum/zinit.mdd ]]; then | |
| # module_path+=( "$HOME/.zinit/module/Src" ) | |
| # zmodload zdharma_continuum/zinit | |
| # fi | |
| ZSH="$HOME/.zinit/plugins/robbyrussell---oh-my-zsh/" | |
| function addToPATH { | |
| PATH="$1:$PATH" | |
| } | |
| # Add PATH for personal utils, it should be fine in zshrc as it's only for interactive use | |
| [[ -d "$HOME/.bin" ]] && addToPATH "$HOME/.bin/" | |
| [[ -d "$HOME/.local/bin" ]] && addToPATH "$HOME/.local/bin/" | |
| [[ -d "$HOME/.pixi/bin" ]] && addToPATH "$HOME/.pixi/bin/" | |
| [[ -d "$HOME/.cargo/bin" ]] && addToPATH "$HOME/.cargo/bin/" | |
| source ~/.zinit/bin/zinit.zsh | |
| # autoload -Uz _zinit | |
| # (( ${+_comps} )) && _comps[zinit]=_zinit | |
| zinit ice atclone"dircolors -b LS_COLORS > clrs.zsh" \ | |
| atpull'%atclone' pick"clrs.zsh" nocompile'!' \ | |
| atload'zstyle ":completion:*" list-colors “${(s.:.)LS_COLORS}”' | |
| zinit light trapd00r/LS_COLORS | |
| zstyle ':completion:*' list-colors "${(@s.:.)LS_COLORS}" | |
| # smart case tab completion | |
| zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' | |
| zmodload -i zsh/complist | |
| # OMZ things to source | |
| local _ZSHRC_OMZ_SOURCES=( | |
| lib/clipboard.zsh | |
| lib/compfix.zsh | |
| lib/directories.zsh | |
| lib/functions.zsh | |
| lib/grep.zsh | |
| lib/history.zsh | |
| lib/key-bindings.zsh | |
| lib/misc.zsh | |
| lib/spectrum.zsh | |
| lib/termsupport.zsh | |
| plugins/extract/extract.plugin.zsh | |
| # lib/completion.zsh | |
| ) | |
| for p in ${_ZSHRC_OMZ_SOURCES[@]};do | |
| zinit ice; zinit snippet OMZ::${p} | |
| done | |
| zinit light-mode for \ | |
| zdharma-continuum/zinit-annex-as-monitor \ | |
| zdharma-continuum/zinit-annex-bin-gem-node \ | |
| zdharma-continuum/zinit-annex-patch-dl \ | |
| zdharma-continuum/zinit-annex-rust | |
| #zinit ice lucid wait"0"; zinit light mafredri/zsh-async | |
| # Imgur | |
| zinit ice lucid wait"5"; zinit snippet 'https://gist.githubusercontent.com/Menchen/47ec8382a95980d660c5850d6a1c058e/raw/imgur.zsh' | |
| # replaced by Atuin | |
| #zinit ice lucid wait"0"; zinit light zdharma-continuum/history-search-multi-word | |
| [[ -n "$commands[jq]" ]] || zinit for \ | |
| lucid\ | |
| as'program' \ | |
| from'gh-r' \ | |
| bpick'jq-*' \ | |
| mv'jq-* -> jq' \ | |
| pick'jq' \ | |
| nocompile \ | |
| jqlang/jq | |
| [[ -n "$commands[fzf]" ]] || zinit pack"binary" for fzf | |
| [[ -n "$commands[nvim]" ]] || zinit for \ | |
| lucid \ | |
| as"program" \ | |
| from'gh-r' \ | |
| bpick'nvim-*'\ | |
| mv'nvim-* -> nvim' \ | |
| pick'nvim' \ | |
| ver'nightly' \ | |
| nocompile \ | |
| neovim/neovim | |
| zinit ice lucid wait"0"; zinit light zsh-users/zsh-history-substring-search | |
| #zsh history search fix | |
| bindkey '\eOA' history-substring-search-up # or ^[OA | |
| bindkey '\eOB' history-substring-search-down # or ^[OB | |
| zinit ice wait"0" as"command" from"gh-r" lucid \ | |
| atclone"./zoxide init zsh > init.zsh" \ | |
| atpull"%atclone" src"init.zsh" | |
| zinit light ajeetdsouza/zoxide | |
| zinit ice lucid wait"0"; zinit light hlissner/zsh-autopair | |
| # Use my own fork with Async race condition patched | |
| ZSH_AUTOSUGGEST_USE_ASYNC=1 | |
| ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=500 | |
| ZSH_AUTOSUGGEST_STRATEGY=(history completion) | |
| zinit ice wait"0" lucid as"command" from"gh-r" bpick"atuin-*.tar.gz" mv"atuin*/atuin -> atuin" \ | |
| atclone"./atuin init zsh --disable-up-arrow > init.zsh; ./atuin gen-completions --shell zsh > _atuin" \ | |
| atpull"%atclone" src"init.zsh" | |
| zinit light atuinsh/atuin | |
| # powerlevel10k | |
| zinit ice depth=1; zinit light romkatv/powerlevel10k | |
| ZSH_THEME="romkatv/powerlevel10k" | |
| if [[ "$TERM" == "linux" ]] || zmodload zsh/terminfo && (( terminfo[colors] < 256 )); then | |
| # Use 16 color for compatibility | |
| export POWERLEVEL9K_CONFIG_FILE="${HOME}/.p10k-16bit.zsh" | |
| [[ -f ~/.p10k-16bit.zsh ]] && source ~/.p10k-16bit.zsh | |
| else | |
| # Use 256 color | |
| [[ -f ~/.p10k.zsh ]] && source ~/.p10k.zsh | |
| fi | |
| # Bitwarden SSH Agent support | |
| [[ -S "${HOME}/.bitwarden-ssh-agent.sock" ]] && export SSH_AUTH_SOCK="${HOME}/.bitwarden-ssh-agent.sock" | |
| # Ghostty | |
| if [[ -n $GHOSTTY_RESOURCES_DIR ]]; then | |
| source "$GHOSTTY_RESOURCES_DIR"/shell-integration/zsh/ghostty-integration | |
| fi | |
| # Uncomment the following line to display red dots whilst waiting for completion. | |
| COMPLETION_WAITING_DOTS="true" | |
| # Command execution time stamp shown in the history command output. | |
| HIST_STAMPS="mm/dd/yyyy" | |
| # Enable Shared History | |
| setopt SHARE_HISTORY | |
| setopt autocd | |
| setopt nonomatch | |
| export GPG_TTY=$TTY | |
| #fzf plugin | |
| [[ -f ~/.fzf.zsh ]] && source ~/.fzf.zsh | |
| if type rg &> /dev/null; then | |
| export FZF_DEFAULT_COMMAND='rg --files' | |
| export FZF_DEFAULT_OPTS='-m --height 50% --border' | |
| fi | |
| # Alias | |
| alias sudo='sudo ' | |
| alias setuslocale="export LANG=en_US.UTF-8" | |
| if [[ -n "$commands[jenv]" ]]; then | |
| alias jenv_set_java_home='export JAVA_HOME="$(jenv javahome)"' | |
| alias java='export JAVA_HOME="$(jenv javahome)";java' | |
| alias javac='export JAVA_HOME="$(jenv javahome)";javac' | |
| alias javadoc='export JAVA_HOME="$(jenv javahome)";javadoc' | |
| fi | |
| if [[ -n "$commands[eza]" ]]; then | |
| # general use | |
| # [[ -n "$commands[dircolors]" ]] && zinit pack for ls_colors | |
| alias ls='eza' # ls | |
| alias l='eza -lb --icons --git' # list, size, type, git | |
| alias ll='eza -lbG --icons --git' # long list | |
| alias llm='eza -lbGd --icons --git --sort=modified' # long list, modified date sort | |
| alias la='eza -lbhHigUmuSa --icons --time-style=long-iso --git --color-scale' # all list | |
| alias lx='eza -lbhHigUmuSa@ --icons --time-style=long-iso --git --color-scale' # all + extended list | |
| # specialty views | |
| alias lS='eza -1' # one column, just names | |
| alias lt='eza --tree --level=2 --icons' # tree | |
| else | |
| alias ls='ls --color=auto' | |
| fi | |
| # Alias | |
| if [[ -n "$commands[lvim]" ]]; then | |
| alias vim=lvim | |
| alias nvim=lvim | |
| export EDITOR=lvim | |
| export VISUAL=lvim | |
| if [[ -n "$commands[nvr]" ]];then | |
| export NVR_CMD=lvim | |
| fi | |
| elif [[ -n "$commands[nvim]" ]]; then | |
| alias vim=nvim | |
| export EDITOR=nvim | |
| export VISUAL=nvim | |
| fi | |
| if [[ -n "$commands[lazygit]" ]]; then | |
| alias lg=lazygit | |
| if [[ -n "$commands[yadm]" ]];then | |
| alias ly='lazygit -ucd ~/.local/share/yadm/lazygit -w ~ -g ~/.local/share/yadm/repo.git' | |
| fi | |
| fi | |
| if [[ -n "$commands[youtube-dl]" ]];then | |
| alias youtube-dl='yt-dlp' | |
| fi | |
| # Askpass | |
| if [[ $(uname) == "Darwin" ]] && [[ -x "/Applications/ssh-askpass.app/Contents/MacOS/ssh-askpass" ]];then | |
| export SSH_ASKPASS="/Applications/ssh-askpass.app/Contents/MacOS/ssh-askpass" | |
| fi | |
| # streamlink iina | |
| if [[ $(uname) == "Darwin" ]] && [[ -n "$commands[iina]" ]] && [[ -n "$commands[streamlink]" ]];then | |
| alias twitchstream='function __twitchstream() { streamlink --twitch-low-latency https://www.twitch.tv/$1 best --stdout 2>/dev/null | iina --stdin &>/dev/null &; unset -f __twitchstream; }; __twitchstream' | |
| fi | |
| zinit ice wait'' lucid nocompile atload"zicompinit; zicdreplay";zinit light Aloxaf/fzf-tab | |
| zinit ice wait'' lucid; zinit light zdharma-continuum/fast-syntax-highlighting | |
| zinit ice wait'' lucid blockf; zinit light zsh-users/zsh-completions | |
| zinit ice wait'' lucid atload"!_zsh_autosuggest_start"; zinit light Menchen/zsh-autosuggestions | |
| # This speeds up pasting w/ autosuggest | |
| # https://github.com/zsh-users/zsh-autosuggestions/issues/238 | |
| pasteinit() { | |
| OLD_SELF_INSERT=${${(s.:.)widgets[self-insert]}[2,3]} | |
| zle -N self-insert url-quote-magic # I wonder if you'd need `.url-quote-magic`? | |
| } | |
| pastefinish() { | |
| zle -N self-insert $OLD_SELF_INSERT | |
| } | |
| zstyle :bracketed-paste-magic paste-init pasteinit | |
| zstyle :bracketed-paste-magic paste-finish pastefinish | |
| # Merge duplicate PATH entry's | |
| typeset -U path | |
| # function zvm_after_init() { | |
| # insert-user-host-cwd() LBUFFER+=${(%):-%n@%m:%~} | |
| # zle -N insert-user-host-cwd | |
| # # bindkey '^T' insert-user-host-cwd | |
| # # bindkey '^T' insert-user-host-cwd | |
| # zvm_bindkey viins '^T' insert-user-host-cwd | |
| # } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment