Skip to content

kebairia/minimal-zsh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Minimal Zsh configuration

logo.png

Info

Mesure startup time:

time zsh -i -c echo

  • -i : force shell to be interactive
  • -c : take the first argument as a command to execute

Enabling profiling

zsh has a builtin profiler to profile startup time usage.

It is called zprof and can be enabled by adding zmodload zsh/zprof

at the top and zprof at the bottom of your /.zshrc.

Source files

import your file here ,i have three different file:

  • aliases: the file that contain all my aliases
  • dir-colors: this file contain really big list of all possible file type with different colors for each category.
  • gruvbox_256palette.sh: this file correct the colors of gruvbox in my terminal.
  • PS: The whole list of the environment variables are in the zshenv file, and these are the most important ones:
    • XDG_CONFIG_HOME: $HOME/.config
    • XDG_CACHE_HOME: $HOME/.cache
    • XDG_DATA_HOME: $HOME/.local/share
    • XDG_BIN_HOME: $HOME/.local/bin
    • XDG_LIB_HOME: $HOME/.local/lib
    • XDG_TMP_HOME: $HOME/.local/tmp
source "$XDG_CONFIG_HOME/misc/aliases"
source "$XDG_DATA_HOME/nvim/plugged/gruvbox/gruvbox_256palette.sh"
if [ -x "$(command -v dircolors)" ]; then
    eval "$(dircolors -b ${XDG_CONFIG_HOME}/misc/dir-colors)"
fi

Completion

Executes commands at the start of an interactive session.

## menu-style
zstyle ':completion:*' menu select
autoload -Uz compinit && compinit
zstyle ':completion:*' special-dirs true
# case insensitive
zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
# Tab completion colors
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
# add new installed packages into completions
zstyle ':completion:*' rehash true
# Use better completion for the kill command
#zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;34'
#zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
# use completion cache
zstyle ':completion::complete:*' use-cache true

Keybinding

bindkey '^[[Z' reverse-menu-complete
bindkey '^[[A' up-line-or-search
bindkey '^[[B' down-line-or-search
bindkey "^P" up-line-or-search
bindkey "^N" down-line-or-search

Shell options

setopt PROMPT_PERCENT
setopt PROMPT_SUBST
# history config
HISTSIZE=1000
SAVEHIST=1000
export HISTFILE="$XDG_DATA_HOME"/zsh/history
# share history across multiple zsh sessions
setopt SHARE_HISTORY
# append to history
setopt APPEND_HISTORY
# expire duplicates first
setopt HIST_EXPIRE_DUPS_FIRST
# do not store duplications
setopt HIST_IGNORE_DUPS
#ignore duplicates when searching
setopt HIST_FIND_NO_DUPS
# removes blank lines from history
setopt HIST_REDUCE_BLANKS
# Correction when you misstype
#setopt CORRECT
#setopt CORRECT_ALL
# use emacs bindings
set -o emacs

Prompt

  • what i need is a clean,minimal and elegant prompt without all the junk and useless info (about everything) clutter in front of me.

img/prompt.png

PROMPT='%b%F{#0b98de}%~ %f
%? %F{#fd9014}%(!.#.>) %f'
autoload -Uz vcs_info
precmd_vcs_info() { vcs_info }
precmd_functions+=( precmd_vcs_info )

zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' stagedstr '%F{yellow}●%f'
zstyle ':vcs_info:*' unstagedstr '%F{red}●%f'
zstyle ':vcs_info:git:*' formats '[%F{green}%b%f%c%u]'
zstyle ':vcs_info:git:*' actionformats '[%F{cyan}%b (%a)%f%c%u]'

RPROMPT='$vcs_info_msg_0_'

Plugins

#auto suggestions
source ~/.config/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
set ZSH_AUTOSUGGEST_USE_ASYNC=true
#fast syntax highlighting
source ~/.config/zsh/plugins/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh
  • PS: The whole list of the environment variables are in the zshenv file, and these are the most important ones: