Skip to content

Instantly share code, notes, and snippets.

@r3nya
Last active January 7, 2026 10:06
Show Gist options
  • Select an option

  • Save r3nya/676c3f643a7ce1e49dd466c19043ae7a to your computer and use it in GitHub Desktop.

Select an option

Save r3nya/676c3f643a7ce1e49dd466c19043ae7a to your computer and use it in GitHub Desktop.
Minimal ZSH setup
# Minimal zsh config with PS1 and fzf history
# Enable colors
autoload -U colors && colors
# Git branch function (standalone, no Oh My Zsh needed)
git_branch() {
local branch=$(git symbolic-ref --short HEAD 2>/dev/null)
if [[ -n "$branch" ]]; then
local dirty=""
[[ -n $(git status --porcelain 2>/dev/null) ]] && dirty=" %{$fg[yellow]%}✗"
echo " %{$fg_bold[blue]%}git:(%{$fg[red]%}$branch%{$fg[blue]%})$dirty%{$reset_color%}"
fi
}
# Enable prompt substitution
setopt PROMPT_SUBST
# PS1 - Robbyrussell style prompt
# Green arrow if last command succeeded, red if failed
# Cyan current directory + git info
PROMPT='%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )%{$fg[cyan]%}%c%{$reset_color%}$(git_branch) '
# History settings
HISTFILE=~/.zsh_history
HISTSIZE=50000
SAVEHIST=50000
setopt SHARE_HISTORY
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_SPACE
# zsh-history-substring-search (Up/Down arrows)
# Type partial command, then use arrows to search history
# Install: brew install zsh-history-substring-search
if [[ -f $(brew --prefix)/share/zsh-history-substring-search/zsh-history-substring-search.zsh ]]; then
source $(brew --prefix)/share/zsh-history-substring-search/zsh-history-substring-search.zsh
bindkey '^[[A' history-substring-search-up # Up arrow
bindkey '^[[B' history-substring-search-down # Down arrow
fi
# fzf fuzzy history search (Ctrl+R)
# Install: brew install fzf
if command -v fzf &>/dev/null; then
fzf-history-widget() {
local selected=$(fc -rln 1 | fzf --height 40% --reverse --tac +s --tiebreak=index)
if [[ -n "$selected" ]]; then
BUFFER="$selected"
CURSOR=$#BUFFER
zle reset-prompt
fi
}
zle -N fzf-history-widget
bindkey '^R' fzf-history-widget
fi
# zsh-autosuggestions (accept with → or End)
# Install: brew install zsh-autosuggestions
[[ -f $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh ]] && \
source $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh
# zsh-syntax-highlighting (MUST be last)
# Install: brew install zsh-syntax-highlighting
[[ -f $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]] && \
source $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

Minimal Zsh Setup

Dependencies

brew install zsh-history-substring-search zsh-autosuggestions zsh-syntax-highlighting fzf

Install

source ~/.zshrc

Features

Keybinding Action
Ctrl+R fzf fuzzy history search
/ Substring history search
Accept autosuggestion
Ctrl+→ Accept next word

Prompt

➜ dirname git:(branch) ✗
  • Green arrow = last command succeeded
  • Red arrow = last command failed
  • Yellow ✗ = uncommitted changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment