ls— title: “My zsh shell configuration” date: 2025-08-17T23:39:36+02:00 #lastmod: 2025-08-17T23:39:36+02:00 draft: true #description : “An optional description for SEO. If not provided, an automatically created summary will be used.”
tags: [“linux”,“mac”,“zsh”,] ¶
This is a page about »My Shell Configuration«. I used fish for a while, but
Sources:
get zsh & packages ¶
sudo port install zsh
sudo port install zsh-syntax-highlighting
sudo port install zsh-autosuggestions
sudo sh -c 'echo /opt/local/bin/zsh >>/etc/shells'
sudo chpass -s '/opt/local/bin/zsh' "$USER"
get fuzzy shell history ¶
I use fzf (see HN discussion (ycombinator.com)). Alternatives are atuin (github.com) or mcfly (github.com).
sudo port install fzf
echo "source /opt/local/share/fzf/shell/key-bindings.zsh" >> ~/.zshrc
echo "source /opt/local/share/fzf/shell/completion.zsh">> ~/.zshrc
tweak .zshrc ¶
From Moving Away From Oh-My-Zsh (github.io) and ~whynothugo/dotfiles (sr.ht)
cat << 'EOF' | tee -a ~/.zshrc
# Goal 1: A nice prompt
PROMPT='%F{33}i%f%F{39}a%f%F{38}n%f%F{44}pan%f%F{50}@%f%F{43}ar%f%F{44}ch%f%F{38}:%1~/%f %F{44}%#%f '
# Goal 2: No duplicate history when reverse-searching my commands
HISTFILE=~/.zsh_history
SAVEHIST=100000 # Max entries saved to file.
HISTSIZE=100000 # Max entires for in-memory history.
# HISTDUP=erase
setopt appendhistory #Append history to the history file (no overwriting)
setopt incappendhistory #Immediately append to the history file, not just when a term is killed
setopt hist_ignore_dups # Collapse two consecutive idential commands.
setopt hist_find_no_dups # Ignore duplicates when searching history.
setopt share_history # Share across concurrent sessions (append immediately, read from files, add timestamps).
setopt hist_ignore_space # Lines that begin with space are not recorded.
setopt hist_verify # Don't auto-execute selected history entry.
setopt hist_ignore_all_dups # If a history entry would be duplicate, delete older copies.
# Goal 3: Case insensitive completion --> solved with fzf
# Goal 4: Emacs-style keybindings
# Ctrl-a: jump to line beginning (same as pressing Home).
# Ctrl-e: jump to line end (same as pressing End).
# Alt-backspace: backspaces a whole word.
# Ctrl-k: delete from current position to end-of-line.
# Ctrl-a Ctrl-k: delete whole line (it’s a combination of “jump to line beginning” and “delete from current position to end-of-line”)
# Alt-b: jump left a whole word
# Alt-f: jump right a whole word
bindkey -e
# Goal 5: Zsh syntax highlighting
source /opt/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
# Goal 6: Get autocompletion
source /opt/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh
export LESS='-RX --mouse --quit-if-one-screen'
alias l="ls -Ah"
alias ll="ls -lAh"
alias grep="grep --color=auto"
EOF