Created
November 25, 2008 19:02
-
-
Save mkhl/29035 to your computer and use it in GitHub Desktop.
Based on the zsh config I'm migrating away from. Will probably be revisited...
This file contains hidden or 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
#!/bin/zsh | |
# | |
# zlogout | |
# zsh-specific logout script | |
# Clear tty | |
if whence tty >/dev/null; then | |
case "$(tty)" in | |
/dev/tty[0-9]*) clear ;; | |
esac | |
fi | |
This file contains hidden or 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
#!/bin/zsh | |
# | |
# zshalias | |
# zsh-specific aliases | |
# Navigating the filesystem | |
alias 1='cd -' | |
alias 2='cd +2' | |
alias 3='cd +3' | |
alias 4='cd +4' | |
alias 5='cd +5' | |
alias 6='cd +6' | |
alias 7='cd +7' | |
alias 8='cd +8' | |
alias 9='cd +9' | |
alias -g ...=../.. | |
alias -g ....=../../.. | |
alias -g .....=../../../.. | |
alias -g ......=../../../../.. | |
alias -g .......=../../../../../.. | |
# Handy shortcuts | |
alias ts=typeset | |
compdef _typeset ts | |
# Better mmv | |
alias mmv='noglob zmv -W' | |
# Fix ls/gls | |
alias ls='ls ${=LS_OPTIONS}' | |
alias gls='gls ${=GLS_OPTIONS}' | |
# Fix which/where | |
alias which >&/dev/null && unalias which | |
# Fix run-help | |
alias run-help >&/dev/null && unalias run-help | |
autoload -U run-help | |
# No spelling correction | |
alias man='nocorrect man' | |
alias mysql='nocorrect mysql' | |
alias mysqlshow='nocorrect mysqlshow' | |
alias mkdir='nocorrect mkdir' | |
alias mv='nocorrect mv' | |
alias rj='nocorrect rj' | |
# Restarting the shell | |
restart () { | |
if jobs | egrep -q . ; then | |
echo "Jobs running; won't restart." >&2 | |
jobs -l >&2 | |
return 1 | |
else | |
exec "$SHELL" $SHELL_ARGS "$@" | |
fi | |
} | |
# Reloading functions or init files | |
reload () { | |
if [[ "$#*" -eq 0 ]]; then | |
unset "SH_RC_DONE" | |
. "$HOME/.zshrc" | |
else | |
local fn | |
for fn in "$@"; do | |
unfunction "$fn" | |
autoload -U "$fn" | |
done | |
fi | |
} | |
compdef _functions reload | |
This file contains hidden or 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
#!/bin/zsh | |
# | |
# zshcomp | |
# zsh-specific completion definitions | |
# ls Colors | |
if whence dircolors >/dev/null; then | |
eval $(dircolors -b) | |
elif whence gdircolors >/dev/null; then | |
eval $(gdircolors -b) | |
fi | |
zmodload -i zsh/complist | |
zstyle ':completion:*' list-colors '' | |
zstyle ':completion:*:*:*:*:processes' list-colors \ | |
'=(#b) #([0-9]#)*=0=01;31' | |
zstyle ':completion:*' list-colors "$LS_COLORS" | |
# # {{{ General completion technique | |
# | |
# # zstyle ':completion:*' completer \ | |
# # _complete _prefix _approximate:-one _ignored \ | |
# # _complete:-extended _approximate:-four | |
# zstyle ':completion:*' completer _complete _prefix _ignored _complete:-extended | |
# | |
# zstyle ':completion::prefix-1:*' completer _complete | |
# zstyle ':completion:incremental:*' completer _complete _correct | |
# zstyle ':completion:predict:*' completer _complete | |
# | |
# zstyle ':completion:*:approximate-one:*' max-errors 1 | |
# zstyle ':completion:*:approximate-four:*' max-errors 4 | |
# | |
# # e.g. f-1.j<TAB> would complete to foo-123.jpeg | |
# zstyle ':completion:*:complete-extended:*' \ | |
# matcher 'r:|[.,_-]=* r:|=*' | |
# | |
# # }}} | |
# # {{{ Fancy menu selection when there's ambiguity | |
# | |
# #zstyle ':completion:*' menu yes select interactive | |
# #zstyle ':completion:*' menu yes=long select=long interactive | |
# #zstyle ':completion:*' menu yes=10 select=10 interactive | |
# | |
# # }}} | |
# # {{{ Completion caching | |
# | |
# zstyle ':completion::complete:*' use-cache 1 | |
# zstyle ':completion::complete:*' cache-path ~/.zsh/cache/$HOST | |
# | |
# # }}} | |
# # {{{ Expand partial paths | |
# | |
# # e.g. /u/s/l/D/fs<TAB> would complete to | |
# # /usr/src/linux/Documentation/fs | |
# zstyle ':completion:*' expand 'yes' | |
# zstyle ':completion:*' squeeze-slashes 'yes' | |
# | |
# # }}} | |
# # {{{ Include non-hidden dirs in globbed file completions for certain commands | |
# | |
# #zstyle ':completion::complete:*' \ | |
# # tag-order 'globbed-files directories' all-files | |
# #zstyle ':completion::complete:*:tar:directories' file-patterns '*~.*(-/)' | |
# | |
# # }}} | |
# # {{{ Don't complete backup files (e.g. 'bin/foo~') as executables | |
# | |
# zstyle ':completion:*:complete:-command-::commands' ignored-patterns '*\~' | |
# | |
# # }}} | |
# # {{{ Don't complete uninteresting users | |
# | |
# zstyle ':completion:*:*:*:users' ignored-patterns \ | |
# adm apache bin daemon games gdm halt ident junkbust lp mail mailnull \ | |
# named news nfsnobody nobody nscd ntp operator pcap postgres radvd \ | |
# rpc rpcuser rpm shutdown squid sshd sync uucp vcsa xfs | |
# | |
# # ... unless we really want to. | |
# zstyle '*' single-ignored show | |
# | |
# # }}} | |
# # {{{ Output formatting | |
# | |
# # Separate matches into groups | |
# zstyle ':completion:*:matches' group 'yes' | |
# | |
# # Describe each match group. | |
# zstyle ':completion:*:descriptions' format "%B---- %d%b" | |
# | |
# # Messages/warnings format | |
# zstyle ':completion:*:messages' format '%B%U---- %d%u%b' | |
# zstyle ':completion:*:warnings' format '%B%U---- no match for: %d%u%b' | |
# | |
# # Describe options in full | |
# zstyle ':completion:*:options' description 'yes' | |
# zstyle ':completion:*:options' auto-description '%d' | |
# | |
# # }}} | |
# # {{{ Array/association subscripts | |
# | |
# # When completing inside array or association subscripts, the array | |
# # elements are more useful than parameters so complete them first: | |
# zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters | |
# | |
# # }}} | |
# # {{{ Completion for processes | |
# | |
# zstyle ':completion:*:*:*:*:processes' menu yes select | |
# zstyle ':completion:*:*:*:*:processes' force-list always | |
# | |
# # }}} | |
# # {{{ Simulate my old dabbrev-expand 3.0.5 patch | |
# | |
# zstyle ':completion:*:history-words' stop yes | |
# zstyle ':completion:*:history-words' remove-all-dups yes | |
# zstyle ':completion:*:history-words' list false | |
# zstyle ':completion:*:history-words' menu yes | |
# | |
# # }}} | |
# # {{{ Usernames | |
# | |
# run_hooks .zsh/users.d | |
# zstyle ':completion:*' users $zsh_users | |
# | |
# # }}} | |
# # {{{ Hostnames | |
# | |
# if [[ "$ZSH_VERSION_TYPE" == 'new' ]]; then | |
# # Extract hosts from /etc/hosts | |
# : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}} | |
# # _ssh_known_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[0-9]*}%%\ *}%%,*}) | |
# else | |
# # Older versions don't like the above cruft | |
# _etc_hosts=() | |
# fi | |
# | |
# zsh_hosts=( | |
# "$_etc_hosts[@]" | |
# localhost | |
# ) | |
# | |
# run_hooks .zsh/hosts.d | |
# zstyle ':completion:*' hosts $zsh_hosts | |
# | |
# # }}} | |
# # {{{ (user, host) account pairs | |
# | |
# run_hooks .zsh/accounts.d | |
# zstyle ':completion:*:my-accounts' users-hosts "$my_accounts[@]" | |
# zstyle ':completion:*:other-accounts' users-hosts "$other_accounts[@]" | |
# | |
# # }}} | |
# | |
# compdef _pdf pdf | |
# | |
# # }}} | |
This file contains hidden or 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
#!/bin/zsh | |
# | |
# zshenv | |
# zsh-specific environment settings | |
setopt extended_glob | |
# We're running the Z Shell | |
is=zsh | |
# Don't recurse | |
test -z "$SH_ENV_DONE" || return | |
SH_ENV_DONE=t | |
# Load shared environment | |
[[ -e "$HOME/.env" ]] && . "$HOME/.env" | |
# Set up search path variables | |
typeset -T INFOPATH infopath | |
typeset -T DYLD_FRAMEWORK_PATH dyld_framework_path | |
typeset -T DYLD_LIBRARY_PATH dyld_library_path | |
typeset -T LD_LIBRARY_PATH ld_library_path | |
typeset -T PERL5LIB perl5lib | |
typeset -T PYTHONPATH pythonpath | |
typeset -T RUBYLIB rubylib | |
# Ignore duplicates | |
typeset -U path | |
typeset -U manpath | |
typeset -U infopath | |
typeset -U dyld_framework_path | |
typeset -U dyld_library_path | |
typeset -U ld_library_path | |
typeset -U perl5lib | |
typeset -U pythonpath | |
typeset -U rubylib | |
# Set library search path variables | |
perl5lib=( | |
$HOME/lib/perl | |
$perl5lib | |
) | |
pythonpath=( | |
$HOME/lib/python | |
$pythonpath | |
) | |
rubylib=( | |
$HOME/lib/ruby | |
$rubylib | |
) | |
fpath=( | |
$HOME/lib/zsh | |
$fpath | |
) | |
# Autoload shell functions from all directories in $fpath. Restrict | |
# functions from $HOME/lib/zsh to ones that have the executable bit | |
# on. (The executable bit is not necessary, but gives you an easy way | |
# to stop the autoloading of a particular shell function). | |
for dirname in $fpath; do | |
case "$dirname" in | |
$HOME/lib/zsh) fns=( $dirname/*~*~(-N.x:t) ) ;; | |
*) fns=( $dirname/*~*~(-N.:t) ) ;; | |
esac | |
done | |
# Make fpath globally available | |
typeset -gU fpath | |
This file contains hidden or 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
#!/bin/zsh | |
# | |
# zshkeys | |
# zsh-specific key bindings | |
# Key Binding Modules | |
zmodload zsh/deltochar | |
# Key Binding Functions | |
_my_long_wordchars="$WORDCHARS" | |
_my_short_wordchars="$(echo "$WORDCHARS"|tr -d /)" | |
is_backslash_quoted () { | |
test "${BUFFER[$CURSOR-1,CURSOR-1]}" = "\\" | |
} | |
unquote-backward-word () { | |
while is_backslash_quoted | |
do zle .backward-word | |
done | |
} | |
unquote-forward-word () { | |
while is_backslash_quoted | |
do zle .forward-word | |
done | |
} | |
backward-to-space () { | |
local WORDCHARS="${_my_long_wordchars}" | |
zle .backward-word | |
unquote-backward-word | |
} | |
forward-to-space () { | |
local WORDCHARS="${_my_long_wordchars}" | |
zle .forward-word | |
unquote-forward-word | |
} | |
backward-to-slash () { | |
local WORDCHARS="${_my_short_wordchars}" | |
zle .backward-word | |
unquote-backward-word | |
} | |
forward-to-slash () { | |
local WORDCHARS="${_my_short_wordchars}" | |
zle .forward-word | |
unquote-forward-word | |
} | |
zle -N backward-to-space | |
zle -N forward-to-space | |
zle -N backward-to-slash | |
zle -N forward-to-slash | |
# Key Bindings | |
bindkey '^[b' backward-to-space | |
bindkey '^[f' forward-to-space | |
bindkey '^[^b' backward-to-slash | |
bindkey '^[^f' forward-to-slash | |
bindkey '^[[5D' backward-to-slash # Ctrl-Left | |
bindkey '^[[5C' forward-to-slash # Ctrl-Right | |
bindkey '^[P' history-beginning-search-backward | |
bindkey '^[N' history-beginning-search-forward | |
bindkey '^[[5A' history-beginning-search-backward # Ctrl-Up | |
bindkey '^[[5B' history-beginning-search-forward # Ctrl-Down | |
bindkey '^X^N' accept-and-infer-next-history | |
# reverse-menu-complete is broken in X.5's shipping Zsh | |
# bindkey '^[[Z' reverse-menu-complete # Shift-Tab | |
# bindkey '^[^I' reverse-menu-complete | |
bindkey '^[[Z' menu-complete # Shift-Tab | |
bindkey '^[^I' menu-complete # Shift-Tab | |
bindkey -s '^[H' ' --help' | |
bindkey -s '^[V' ' --version' | |
bindkey -s '^X^Z' '%-^M' | |
bindkey '^[e' expand-cmd-path | |
bindkey '^[z' zap-to-char | |
bindkey '^[Z' delete-to-char | |
This file contains hidden or 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
#!/bin/zsh | |
# | |
# zshrc | |
# zsh-specific interactive settings | |
emulate -R zsh | |
# Don't recurse | |
test -z "$SH_RC_DONE" || return | |
SH_RC_DONE=t | |
# Zsh options | |
opts=( | |
# Changing Directories | |
auto_cd | |
auto_pushd | |
pushd_ignore_dups | |
# pushd_minus | |
pushd_silent | |
pushd_to_home | |
# Completion | |
list_rows_first | |
NO_rec_exact # Some distros set this... | |
# Expansion and Globbing | |
# csh_null_glob | |
extended_glob | |
# null_glob | |
# History | |
hist_ignore_all_dups | |
# hist_ignore_space | |
hist_no_store | |
hist_reduce_blanks | |
inc_append_history | |
# Input/Output | |
NO_clobber | |
# correct | |
# dvorak | |
sun_keyboard_hack | |
# Zle | |
emacs | |
) | |
setopt $opts | |
unset -v opts | |
# Autoload modules | |
autoload -U zargs zcalc zmv | |
# Augment PATH | |
path=($path "$HOME/bin" .) | |
# Completion listing | |
LISTMAX=0 | |
# History | |
HISTFILE="$HOME/.${is}_history" | |
HISTSIZE=5000 | |
SAVEHIST=5000 | |
# Prompt | |
autoload -U promptinit | |
promptinit | |
if [[ -e "$HOME/.${is}prompt" ]]; then | |
. "$HOME/.${is}prompt" | |
else | |
prompt walters blue | |
fi | |
# Hosts | |
# : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}} | |
# _ssh_known_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[0-9]*}%%\ *}%%,*}) | |
# Pager | |
which lesspipe.sh >/dev/null && export LESSOPEN="|$(which lesspipe.sh) %s" | |
READNULLCMD="$PAGER" | |
# Path | |
# Prepend GNU utils to Path. | |
path-gnu () { | |
path=(/opt/gnu/bin $path) | |
} | |
# Prepend Macports in Path. | |
path-macports () { | |
path=(/opt/local/{,s}bin $path) | |
} | |
# Completion system... | |
autoload -U compinit | |
compinit | |
# compinit -u # use with care!! | |
if [[ -e "$HOME/.${is}comp" ]]; then | |
. "$HOME/.${is}comp" | |
else | |
: # ... | |
fi | |
# Load shared aliases | |
[[ -e "$HOME/.alias" ]] && . "$HOME/.alias" | |
# More aliases | |
[[ -e "$HOME/.${is}alias" ]] && . "$HOME/.${is}alias" | |
# MIME handling | |
autoload -U zsh-mime-setup | |
zsh-mime-setup | |
# Key Bindings | |
[[ -e "$HOME/.${is}keys" ]] && . "$HOME/.${is}keys" | |
# All done | |
true | |
### Adam Spiers' zshrc | |
# # {{{ Global aliases | |
# | |
# # WARNING: global aliases are evil. Use with caution. | |
# | |
# # {{{ For screwed up keyboards missing pipe | |
# | |
# alias -g PIPE='|' | |
# | |
# # }}} | |
# # {{{ Paging with less / head / tail | |
# | |
# alias -g L='| less' | |
# alias -g LS='| less -S' | |
# alias -g EL='|& less' | |
# alias -g ELS='|& less -S' | |
# alias -g TRIM='| cut -c 1-$COLUMNS' | |
# | |
# alias -g H='| head' | |
# alias -g HL='| head -n $(( +LINES ? LINES - 4 : 20 ))' | |
# alias -g EH='|& head' | |
# alias -g EHL='|& head -n $(( +LINES ? LINES - 4 : 20 ))' | |
# | |
# alias -g T='| tail' | |
# alias -g TL='| tail -n $(( +LINES ? LINES - 4 : 20 ))' | |
# alias -g ET='|& tail' | |
# alias -g ETL='|& tail -n $(( +LINES ? LINES - 4 : 20 ))' | |
# | |
# # }}} | |
# # {{{ Sorting / counting | |
# | |
# alias -g C='| wc -l' | |
# | |
# alias -g S='| sort' | |
# alias -g Su='| sort -u' | |
# alias -g Sn='| sort -n' | |
# alias -g Snr='| sort -nr' | |
# | |
# # }}} | |
# # {{{ Common filenames | |
# | |
# alias -g DN=/dev/null | |
# alias -g DZ=/dev/zero | |
# alias -g VM=/var/log/messages | |
# | |
# # }}} | |
# # {{{ grep, xargs | |
# | |
# # see also grep-shortcuts script | |
# for switches in {,i}{,l,L}{,r}{,v}; do | |
# eval "alias -g G$switches='| egrep ${switches:+-$switches}'" | |
# eval "alias -g EG$switches='|& egrep ${switches:+-$switches}'" | |
# eval "alias -g XG$switches='| xargs egrep ${switches:+-$switches}'" | |
# eval "alias -g X0G$switches='| xargs -0 egrep ${switches:+-$switches}'" | |
# done | |
# | |
# alias -g XA='| xargs' | |
# alias -g X0='| xargs -0' | |
# | |
# # }}} | |
# # {{{ awk | |
# | |
# alias -g A='| awk ' | |
# alias -g A1="| awk '{print \$1}'" | |
# alias -g A2="| awk '{print \$2}'" | |
# alias -g A3="| awk '{print \$3}'" | |
# alias -g A4="| awk '{print \$4}'" | |
# alias -g A5="| awk '{print \$5}'" | |
# alias -g A6="| awk '{print \$6}'" | |
# alias -g A7="| awk '{print \$7}'" | |
# alias -g A8="| awk '{print \$8}'" | |
# alias -g A9="| awk '{print \$9}'" | |
# alias -g EA='|& awk ' | |
# alias -g EA1="|& awk '{print \$1}'" | |
# alias -g EA2="|& awk '{print \$2}'" | |
# alias -g EA3="|& awk '{print \$3}'" | |
# alias -g EA4="|& awk '{print \$4}'" | |
# alias -g EA5="|& awk '{print \$5}'" | |
# alias -g EA6="|& awk '{print \$6}'" | |
# alias -g EA7="|& awk '{print \$7}'" | |
# alias -g EA8="|& awk '{print \$8}'" | |
# alias -g EA9="|& awk '{print \$9}'" | |
# | |
# # }}} | |
# | |
# # }}} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment