Skip to content

Instantly share code, notes, and snippets.

@untainsYD
Created May 12, 2023 15:33
Show Gist options
  • Save untainsYD/5c8746b0579fb26fe0c6233054209ccd to your computer and use it in GitHub Desktop.
Save untainsYD/5c8746b0579fb26fe0c6233054209ccd to your computer and use it in GitHub Desktop.
.zshrc configuration file
```
dot_config="${XDG_CONFIG_HOME:-$HOME/.config}/zsh"
partials="${dot_config}/zshrc.d"
zstyle ':completion:*' completer _expand _complete _ignored _approximate
zstyle ':completion:*' matcher-list '' '' 'm:{[:lower:]}={[:upper:]} m:{[:lower:][:upper:]}={[:upper:][:lower:]} r:|[._-]=** r:|=** l:|=*'
zstyle ':completion:*:*:*:*:descriptions' format '%F{green}-- %d --%f'
zstyle ':completion:*:*:*:*:corrections' format '%F{yellow}!- %d (errors: %e) -!%f'
zstyle ':completion:*:descriptions' format '%U%K{yellow} %F{green}-- %F{red} %BNICE!1! %b%f %d --%f%k%u'
zstyle ':completion:*:default' list-colors "${(s.:.)LS_COLORS}"
zstyle ':completion:*' group-name ''
zstyle ':completion:*' menu select=2
zstyle ':completion:*' rehash true
zstyle :compinstall filename '$ZDOTDIR/.zshrc'
# BEGIN :Options
setopt AUTO_CD # Go to folder path without using cd.
setopt AUTO_NAME_DIRS # Any parameter that is set to the absolute name of a directory immediately becomes a name for that directory
setopt AUTO_PUSHD # Push the old directory onto the stack on cd.
setopt CDABLE_VARS # Change directory to a path stored in a variable.
setopt CORRECT # Spelling correction
setopt CORRECTALL
setopt EXTENDED_GLOB # Use extended globbing syntax.
setopt GLOB_DOTS # Do not require a leading '.' in a filename to be matched explicitly.
setopt INTERACTIVE_COMMENTS # Allow comments even in interactive shells
setopt MAGIC_EQUAL_SUBST # All unquoted arguments of the form 'anything=expression' appearing after the command name have filename expansion
setopt NOTIFY # Report the status of background jobs immediately, rather than waiting until just before printing a prompt.
setopt PROMPT_SUBST # If set, parameter expansion, command substitution and arithmetic expansion are performed in prompts.
setopt PUSHD_IGNORE_DUPS # Do not store duplicates in the stack.
setopt PUSHD_SILENT # Do not print the directory stack after pushd or popd.
## History
setopt EXTENDED_HISTORY # Write the history file in the ':start:elapsed;command' format.
setopt HIST_EXPIRE_DUPS_FIRST # Expire a duplicate event first when trimming history.
setopt HIST_FIND_NO_DUPS # Do not display a previously found event.
setopt HIST_IGNORE_ALL_DUPS # Delete an old recorded event if a new event is a duplicate.
setopt HIST_IGNORE_DUPS # Do not record an event that was just recorded again.
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 SHARE_HISTORY # Share history between all sessions.
unsetopt nomatch # escape string fixing zsh: no matches found error
# END: options
typeset -U path # tells the shell that it should not add anything to $path if it's there already.
autoload -Uz colors
colors
zmodload zsh/complist
autoload -Uz compinit
autoload -Uz edit-command-line
zle -N edit-command-line
# BEGIN: Navigation
autoload -Uz up-line-or-beginning-search down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
# END: navigation
# BEGIN: Helpers
command_exists () {
(( $+commands[$1] ))
}
# END: helpers
# BEGIN: sudo
export SUDO=''
if [[ $EUID -ne 0 ]] && command_exists sudo ; then
export SUDO='sudo'
fi
# END: sudo
# BEGIN: Import additional files
## custom functions
source $partials/func.zsh
## Sourcing partials
source "$partials/alias.zsh"
## source it after zsh-vi-mode and others bindkeys modifiers
source "$partials/bindkeys.zsh"
# END: import additional files
# BEGIN: Tabs
tabs -4
# END: tabs
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment