Skip to content

Instantly share code, notes, and snippets.

@adliwahid
Last active Feb 1, 2021
Embed
What would you like to do?
minimal zsh configuragion (.zshrc)
# https://scriptingosx.com/2019/06/moving-to-zsh-part-3-shell-options/
# notes from https://thevaluable.dev/zsh-install-configure/
export PATH="/usr/local/sbin:$PATH"
PROMPT='%F{cyan}%n%f%F{yellow}@[%m]%f in %F{green}%~%f -> '
#prompt on the right side
RPROMPT='%*'
# aliases
alias ll='ls -lath'
# Options
setopt NO_CASE_GLOB
setopt AUTO_CD #change directory with dir name
setopt EXTENDED_HISTORY #add timestamp in history
# share history across multiple zsh sessions
setopt SHARE_HISTORY
# append to history
setopt APPEND_HISTORY
# adds commands as they are typed, not at shell exit
setopt INC_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
#correct typos in commands & suggest
setopt CORRECT
setopt CORRECT_ALL
# https://github.com/Phantas0s/.dotfiles/blob/master/zsh/plugins/completion.zsh
# Populate hostname completion. But allow ignoring custom entries from static
# */etc/hosts* which might be uninteresting.
# Initialize the autocompletion
autoload -Uz compinit && compinit -i
zstyle -e ':completion:*:hosts' hosts 'reply=(
${=${=${=${${(f)"$(cat {/etc/ssh/ssh_,~/.ssh/}known_hosts(|2)(N) 2> /dev/null)"}%%[#| ]*}//\]:[0-9]*/ }//,/ }//\[/ }
${=${(f)"$(cat /etc/hosts(|)(N) <<(ypcat hosts 2> /dev/null))"}%%(\#${_etc_host_ignores:+|${(j:|:)~_etc_host_ignores}})*}
${=${${${${(@M)${(f)"$(cat ~/.ssh/config 2> /dev/null)"}:#Host *}#Host }:#*\**}:#*\?*}}
)'
# SSH/SCP/RSYNC
zstyle ':completion:*:(ssh|scp|rsync):*' tag-order 'hosts:-host:host hosts:-domain:domain hosts:-ipaddr:ip\ address *'
zstyle ':completion:*:(scp|rsync):*' group-order users files all-files hosts-domain hosts-host hosts-ipaddr
zstyle ':completion:*:ssh:*' group-order users hosts-domain hosts-host users hosts-ipaddr
zstyle ':completion:*:(ssh|scp|rsync):*:hosts-host' ignored-patterns '*(.|:)*' loopback ip6-loopback localhost ip6-localhost broadcasthost
zstyle ':completion:*:(ssh|scp|rsync):*:hosts-domain' ignored-patterns '<->.<->.<->.<->' '^[-[:alnum:]]##(.[-[:alnum:]]##)##' '*@*'
zstyle ':completion:*:(ssh|scp|rsync):*:hosts-ipaddr' ignored-patterns '^(<->.<->.<->.<->|(|::)([[:xdigit:].]##:(#c,2))##(|%*))' '127.0.0.<->
' '255.255.255.255' '::1' 'fe80::*'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment