Last active
May 29, 2024 01:45
-
-
Save scottstanfield/fa1085c225069160225d18b1dc16ee1c to your computer and use it in GitHub Desktop.
sensible, minimal .zshrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sensible, short .zshrc | |
# Gist page: git.io/vSBRk | |
# Raw file: curl -L git.io/sensible-zshrc | |
# GNU and BSD (macOS) ls flags aren't compatible | |
ls --version &>/dev/null | |
if [ $? -eq 0 ]; then | |
lsflags="--color --group-directories-first -F" | |
else | |
lsflags="-GF" | |
export CLICOLOR=1 | |
fi | |
# Aliases | |
alias ls="ls ${lsflags}" | |
alias ll="ls ${lsflags} -l" | |
alias la="ls ${lsflags} -la" | |
alias h="history" | |
alias hg="history -1000 | grep -i" | |
alias ,="cd .." | |
alias m="less" | |
# GIT | |
# Do this: git config --global url.ssh://[email protected]/.insteadOf https://github.com | |
alias gd="git diff" | |
alias gs="git status 2>/dev/null" | |
function gc() { git clone ssh://[email protected]/"$*" } | |
function gg() { git commit -m "$*" } | |
# More suitable for .zshenv | |
EDITOR=vim | |
PROMPT='%n@%m %3~%(!.#.$)%(?.. [%?]) ' | |
# History settings | |
HISTFILE=~/.history-zsh | |
HISTSIZE=10000 | |
SAVEHIST=10000 | |
setopt append_history # allow multiple sessions to append to one history | |
setopt bang_hist # treat ! special during command expansion | |
setopt extended_history # Write history in :start:elasped;command format | |
setopt hist_expire_dups_first # expire duplicates first when trimming history | |
setopt hist_find_no_dups # When searching history, don't repeat | |
setopt hist_ignore_dups # ignore duplicate entries of previous events | |
setopt hist_ignore_space # prefix command with a space to skip it's recording | |
setopt hist_reduce_blanks # Remove extra blanks from each command added to history | |
setopt hist_verify # Don't execute immediately upon history expansion | |
setopt inc_append_history # Write to history file immediately, not when shell quits | |
setopt share_history # Share history among all sessions | |
# Tab completion | |
autoload -Uz compinit && compinit | |
setopt complete_in_word # cd /ho/sco/tm<TAB> expands to /home/scott/tmp | |
setopt auto_menu # show completion menu on succesive tab presses | |
setopt autocd # cd to a folder just by typing it's name | |
ZLE_REMOVE_SUFFIX_CHARS=$' \t\n;&' # These "eat" the auto prior space after a tab complete | |
# MISC | |
setopt interactive_comments # allow # comments in shell; good for copy/paste | |
unsetopt correct_all # I don't care for 'suggestions' from ZSH | |
export BLOCK_SIZE="'1" # Add commas to file sizes | |
# PATH | |
typeset -U path # keep duplicates out of the path | |
path+=(.) # append current directory to path (controversial) | |
# BINDKEY | |
bindkey -e | |
bindkey '\e[3~' delete-char | |
bindkey '^p' history-search-backward | |
bindkey '^n' history-search-forward | |
bindkey ' ' magic-space | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sensible, slightly opinionated ZSH settings in a single file
Install ZSH on Ubuntu
Install ZSH on macOS
Use sensible defaults .zshrc
Exit your shell and log back in to see the changes.
Features
ls
works with GNU or macOS: groups folders first, uses color and appends a slash for directories