#!/usr/bin/env zsh # # Set completion style # The following lines were added by compinstall zstyle ':completion:*' completer _complete _ignored _approximate zstyle ':completion:*' list-colors '' zstyle ':completion:*' matcher-list '' '+m:{[:lower:]}={[:upper:]} r:|[._-]=** r:|=**' zstyle ':completion:*' menu select=1 zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s zstyle :compinstall filename '/home/marty/.config/zsh/.zshrc' # End of lines added by compinstall autoload -Uz compinit zmv compinit # Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.config/zsh/.zshrc. # Initialization code that may require console input (password prompts, [y/n] # confirmations, etc.) must go above this block, everything else may go below. 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 # load all plugins [ -f "$XDG_CONFIG_HOME/zsh/plugins.zsh" ] && source "$XDG_CONFIG_HOME/zsh/plugins.zsh" # shellcheck source=alias [ -f "$XDG_CONFIG_HOME/sh/alias" ] && source "$XDG_CONFIG_HOME/sh/alias" # load additional aliases if [ -d "$XDG_CONFIG_HOME/sh/alias.d" ]; then for _alias in "$XDG_CONFIG_HOME/sh/alias.d"/*.sh; do . "$_alias" done unset _alias fi # Correct spelling for commands setopt correct # turn off the infernal correctall for filenames unsetopt correctall # Enable command auto-correction. ENABLE_CORRECTION="true" # Speed up autocomplete, force prefix mapping zstyle ':completion:*' accept-exact '*(N)' zstyle ':completion:*' use-cache on zstyle ':completion:*' cache-path ~/.zsh/cache # shellcheck disable=SC2016 zstyle -e ':completion:*:default' list-colors 'reply=("${PREFIX:+=(#bi)($PREFIX:t)*==34=34}:${(s.:.)LS_COLORS}")' ### history ## Set ZSH History defaults setopt append_history setopt extended_history setopt hist_expire_dups_first setopt hist_ignore_all_dups setopt hist_ignore_dups setopt hist_ignore_space setopt hist_reduce_blanks setopt hist_save_no_dups setopt hist_verify # Share your history across all your terminal windows setopt share_history setopt pushd_ignore_dups #setopt pushd_silent export HISTSIZE=100000 export SAVEHIST=100000 export HISTFILE="$XDG_DATA_HOME/zsh_history" export HISTIGNORE="ls:cd:cd -:pwd:exit:date:* --help" ## Set ZSH History aliases # Show the top 5 commands used in recent history history_top() { history | awk "{a[\$2]++} END{for(i in a){printf \"%5d\t%s\n\",a[i],i}}" | sort -rn | head } # Display timestamped recent command history alias history="fc -l -d -D" ### Glob Alias expansion # Expand aliases inline - see http://blog.patshead.com/2012/11/automatically-expaning-zsh-global-aliases---simplified.html globalias() { if [[ $LBUFFER =~ [A-Z0-9]+$ ]]; then zle _expand_alias zle expand-word fi zle self-insert } zle -N globalias bindkey " " globalias bindkey "^ " magic-space # control-space to bypass completion bindkey -M isearch " " magic-space # normal space during searches # To customize prompt, run `p10k configure` or edit ~/.config/zsh/.p10k.zsh. [[ ! -f "$XDG_CONFIG_HOME"/zsh/.p10k.zsh ]] || source "$XDG_CONFIG_HOME"/zsh/.p10k.zsh # In case a plugin adds a redundant path entry, remove duplicate entries # from PATH # from: https://unix.stackexchange.com/questions/40749/remove-duplicate-path-entries-with-awk-command get_var() { eval 'printf "%s\n" "${'"$1"'}"' } set_var() { eval "$1=\"\$2\"" } dedup_pathvar() { pathvar_name="$1" pathvar_value="$(get_var "$pathvar_name")" deduped_path="$(perl -e 'print join(":",grep { not $seen{$_}++ } split(/:/, $ARGV[0]))' "$pathvar_value")" set_var "$pathvar_name" "$deduped_path" } dedup_pathvar PATH dedup_pathvar MANPATH