Skip to content

Instantly share code, notes, and snippets.

@KROSF
Last active March 16, 2024 12:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save KROSF/175236cde9c207e60c4d78e564bae571 to your computer and use it in GitHub Desktop.
Save KROSF/175236cde9c207e60c4d78e564bae571 to your computer and use it in GitHub Desktop.
Configuring ZSH

Configure ZSH using zplug and starship

Steps

Install zplug

curl -sL --proto-redir -all,https https://raw.githubusercontent.com/zplug/installer/master/installer.zsh | zsh

Install starship

curl -fsSL https://starship.rs/install.sh | bash

Install the SourceCodePro Nerd font

curl -LO https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/SourceCodePro.zip
unzip SourceCodePro.zip -d $HOME/.local/share/fonts/NerdFonts

Set your terminal font to SauceCodePro Nerd Font

Add the following config to your ~/.zshrc

export LANG=en_US.UTF-8
source $ZPLUG_HOME/init.zsh

zplug "zsh-users/zsh-completions"
zplug "zsh-users/zsh-syntax-highlighting", defer:2
zplug "zsh-users/zsh-autosuggestions", use:"zsh-autosuggestions.zsh"
zplug "zsh-users/zsh-history-substring-search", defer:3
zplug "docker/cli", use:contrib/completion/zsh, defer:3
zplug "docker/compose", use:contrib/completion/zsh, defer:3
zplug "rupa/z", use:z.sh

zplug "lib/completion", from:oh-my-zsh
zplug 'modules/history', from:prezto
zplug 'modules/git', from:prezto
zplug 'modules/utility', from:prezto
zplug 'modules/editor', from:prezto

zstyle ':prezto:*:*' color 'yes'

if ! zplug check --verbose; then
    printf "Install? [y/N]: "
    if read -q; then
        echo; zplug install
    fi
fi

zplug load

if zplug check "zsh-users/zsh-history-substring-search"; then
  zmodload zsh/terminfo
  [ -n "${terminfo[kcuu1]}" ] && bindkey "${terminfo[kcuu1]}" history-substring-search-up
  [ -n "${terminfo[kcud1]}" ] && bindkey "${terminfo[kcud1]}" history-substring-search-down
  bindkey '^[[A' history-substring-search-up
  bindkey '^[[B' history-substring-search-down
  bindkey -M vicmd 'k' history-substring-search-up
  bindkey -M vicmd 'j' history-substring-search-down
  # For iTerm2 running on Apple MacBook laptops
      if [[ -n "$terminfo[cuu1]" ]]; then
        bindkey "$terminfo[cuu1]" history-substring-search-up
      fi
      if [[ -n "$terminfo[cud1]" ]]; then
        bindkey "$terminfo[cud1]" history-substring-search-down
      fi
fi

eval "$(starship init zsh)"

Add the following to your ~/.config/starship.toml or create if does not exist

add_newline = false

[git_branch]
symbol = "\uf418 "

[git_state]
merge = "\uf419 "
cherry_pick = "🍒 PICKING"
revert = ""
rebase = "🔀"

[git_status]
prefix = ""
suffix = ""
conflicted = "\uf440 "
ahead = "🚀 "
behind = "🐢 "
diverged = "\uf493 "
untracked = "\uf474 "
stashed = "\uf472 "
modified = "\uf459 "
staged = "\uf457 "
renamed = "\uf45a "
deleted = "\uf458 "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment