Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Proprositions for a useful categorization of zsh options?



* Thorsten Kampe <thorsten@xxxxxxxxxxxxxxxx> [Apr 21, 2004 19:40]:
> > I have the following folding titles in my ~/.zsh/.zshrc
> >
> > +---  7 lines: 4.1. Parameters and Shell Functionality
> > +---  9 lines: 4.2. Changing Directories
> > +--- 11 lines: 4.3. Shell Completion
> > +---  9 lines: 4.4. Shell Expansion and Globbing
> > +--- 11 lines: 4.5. History and History Expansion
> > +---  7 lines: 4.6. Job Control
> > +---  6 lines: 4.7. Shell Prompt
> > +---  6 lines: 4.8. ZLE
> > +---  8 lines: 4.9. Input and Output
>
> Are the options that belong to that titles top secret ;-)? If you
> could enumerate the respective options it would be useful to us all
> who are interested...

Heh, sorry.  I once set every option in my ~/.zsh/.zshrc, but now I'm
keeping to only those options that differ from the default which
actually only come to 28 (if my quick count is correct).  That's a pretty
good job of setting decent defaults on your (i.e. the developers reading
this) side I must say.  Anyway, here's my setup (I've attached the whole
.zshrc for those interested):



# 4. Shell Options {{{1
# ================


# 4.1. Parameters and Shell Functionality {{{2
# ---------------------------------------

setopt noglobalexport		# don't be backwards compatible
setopt ignoreeof		# ignore EOF ('^D') (i.e. don't log out on it)


# 4.2. Changing Directories {{{2
# -------------------------

setopt autocd			# automatically cd to a directory if not cmd
setopt autopushd		# automatically pushd directories on dirstack
setopt pushdignoredups		# don't push dups on stack
setopt pushdsilent		# be quiet about pushds and popds


# 4.3. Shell Completion {{{2
# ---------------------

setopt automenu			# use menu completion after 2 tabs
setopt completeinword		# complete inside words
setopt correct			# try to correct spelling
setopt dvorak			# we are using dvorak so tell correction that
setopt nolistambiguous		# only list matches if ambiguous
setopt nolistbeep		# don't beep on ambiguous listings


# 4.4. Shell Expansion and Globbing {{{2
# ---------------------------------

setopt extendedglob		# don't use extended globbing (#, ~, ^)
setopt noequals                 # don't expand =cmd
				# TODO: do we really want this?
# setopt globdots		# don't require a dot ('.') to be specifically


# 4.5. History and History Expansion {{{2
# ----------------------------------

setopt extendedhistory		# save timestamps in history
setopt nohistbeep		# don't beep for erroneous history expansions
setopt histignorealldups	# don't ignore dups in history
setopt histignoredups		# ignore consecutive dups in history
setopt histnostore		# don't store history related functions
setopt incappendhistory		# incrementally add items to hist.


# 4.6. Job Control {{{2
# ----------------

setopt longlistjobs		# list jobs in long format
setopt nonotify			# report job status only before prompt printing


# 4.7. Shell Prompt {{{2
# -----------------

setopt promptsubst		# allow paramater, command, so on in prompt


# 4.8. ZLE {{{2
# --------

setopt nobeep			# don't beep on errors (in ZLE)


# 4.9. Input and Output {{{2
# ---------------------

setopt noflowcontrol		# don't use flow control (^S/^Q)
setopt printeightbit		# allow eight bit output for completion lists


# }}}2



# }}}1



enjoy,
	nikolai

--
::: name: Nikolai Weibull    :: aliases: pcp / lone-star / aka :::
::: born: Chicago, IL USA    :: loc atm: Gothenburg, Sweden    :::
::: page: www.pcppopper.org  :: fun atm: gf,lps,ruby,lisp,war3 :::
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}
# contents: zsh(1) user RC file.
# arch-tag: e275f609-4068-474e-9bea-c191ed6cdc7b
#
# Copyright (C) 2002 Nikolai Weibull <source@xxxxxxxxxxxxx>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA



# 1. Parameters {{{1
# =============


# 1.1 Shell Parameters {{{2
# --------------------

                                # hosts to use for completion
hosts=(sourcecontrol.net lab.mdstud.chalmers.se grosse.mdstud.chalmers.se)
watch=(notme)			# users to monitor logins/logouts for


# }}}2



# 2. Limits {{{1
# =========


limit coredumpsize  30m		# limit core dumps to 30mb
limit stacksize	    8m		# limit stack to 8mb



# 3. Shell Settings {{{1
# =================



# 3.1. Shell Directories {{{2
# ----------------------

hash -d rg=~/src/cvs/ruby-gnome2
hash -d ned=~/src/\{projects\}/ned
hash -d pplib=~/src/\{projects\}/pplib
hash -d khz=~/src/ruby/kilohertz
hash -d context=/usr/share/texmf/tex/context


# }}}2



# 4. Shell Options {{{1
# ================


# 4.1. Parameters and Shell Functionality {{{2
# ---------------------------------------

setopt noglobalexport		# don't be backwards compatible
setopt ignoreeof		# ignore EOF ('^D') (i.e. don't log out on it)


# 4.2. Changing Directories {{{2
# -------------------------

setopt autocd			# automatically cd to a directory if not cmd
setopt autopushd		# automatically pushd directories on dirstack
setopt pushdignoredups		# don't push dups on stack
setopt pushdsilent		# be quiet about pushds and popds


# 4.3. Shell Completion {{{2
# ---------------------

setopt automenu			# use menu completion after 2 tabs
setopt completeinword		# complete inside words
setopt correct			# try to correct spelling
setopt dvorak			# we are using dvorak so tell correction that
setopt nolistambiguous		# only list matches if ambiguous
setopt nolistbeep		# don't beep on ambiguous listings


# 4.4. Shell Expansion and Globbing {{{2
# ---------------------------------

setopt extendedglob		# don't use extended globbing (#, ~, ^)
setopt noequals                 # don't expand =cmd
				# TODO: do we really want this?
# setopt globdots		# don't require a dot ('.') to be specifically


# 4.5. History and History Expansion {{{2
# ----------------------------------

setopt extendedhistory		# save timestamps in history
setopt nohistbeep		# don't beep for erroneous history expansions
setopt histignorealldups	# don't ignore dups in history
setopt histignoredups		# ignore consecutive dups in history
setopt histnostore		# don't store history related functions
setopt incappendhistory		# incrementally add items to hist.


# 4.6. Job Control {{{2
# ----------------

setopt longlistjobs		# list jobs in long format
setopt nonotify			# report job status only before prompt printing


# 4.7. Shell Prompt {{{2
# -----------------

setopt promptsubst		# allow paramater, command, so on in prompt


# 4.8. ZLE {{{2
# --------

setopt nobeep			# don't beep on errors (in ZLE)


# 4.9. Input and Output {{{2
# ---------------------

setopt noflowcontrol		# don't use flow control (^S/^Q)
setopt printeightbit		# allow eight bit output for completion lists


# }}}2



# 5. Terminal Settings {{{1
# ====================


# 5.1. Terminal Input {{{2
# -------------------


stty -ixon			# don't use flow control
stty pass8			# but do send 8-bit characters to terminal

unset TERMCAP


# 5.2. Terminal Output {{{2
# --------------------

				# disable audio bell
#case $TERM in
#  *screen*|rxvt|*xterm) echo -e -n "\033[10;0]\033[11;0]" ;;
#esac


# 5.3. Screen Title Updating {{{2
# --------------------------

_set_title ()
{
  case $TERM in
    screen*)
    print -nR $'\033k'$1$'\033'\\
    print -nR $'\033]0;'$2$'\a' ;;
  esac
}

precmd ()
{
  _set_title zsh "$PWD"
}

preexec ()
{
  emulate -L zsh
  local -a cmd;

  cmd=(${(z)1})
  _set_title $cmd[1]:t "$cmd[2,-1]"
}


# }}}2



# 6. Modules {{{1
# ==========


# 6.1. Default ZSH Modules {{{2
# ------------------------

zmodload -a zsh/stat stat	# provide `stat' command
zmodload -a zsh/zpty zpty	# provide pty manipulating command
zmodload -a zsh/zpprof zprof	# provide `zprof' command (profiling of funcs)
				# provide `mapfile' command when requested
zmodload -ap zsh/mapfile mapfile 
zmodload -i zsh/complist 	# load completion listing extensions


# 6.2. ZFTP {{{2
# ---------

zmodload -a zsh/zmodload zftp 	# load zftp module
autoload -U zfinit		# initialize the whole `zftp' subsystem
zfinit
				# where we shall store our bookmarks
ZFTP_BMFILE="$ZDOTDIR/.zfbookmarks" 
ZFTP_PREFS="PS"			# try passive, then sendport
ZFTP_TMOUT="60"			# timeout in seconds

export ZFTP_BMFILE ZFTP_PREFS ZFTP_TMOUT


# }}}2



# 7. Command-line Completion {{{1
# ==========================


# 7.1. Startup {{{2
# ------------

autoload -U colors 		# we need the colors for some formats below
colors
autoload -U compinit		# setup the new style completion system
compinit


# 7.2. Completion Styles {{{2
# ----------------------

				# turn off compctl-style completion support
zstyle ':completion:*' use-compctl false
				# host completion
zstyle '*' hosts $hosts
zstyle ':completion:*' squeeze-slashes yes
                                # disable equal subst
compdef -d -- -equal-


# 7.2.1. Caching {{{3

				# completion cache path
zstyle ':completion::complete:*' use-cache 1
zstyle ':completion::complete:*' cache-path $ZDOTDIR/cache/$HOST

# 7.2.2. Completers {{{3

				# list of different completers to use
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
				# allow one error for every three characters
				# typed in approximate completer
zstyle -e ':completion:*:approximate:*' max-errors \
  'reply=($(( ($#PREFIX+$#SUFFIX)/3 )) numeric)'
zstyle ':completion:*:complete-extended:*' matcher 'r:|[.,_-]=* r:|=*'

# 7.2.3. Completer Options {{{3

				# match uppercase from lowercase
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
				# offer indexes before parameters in subscripts
zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters
				# ignore completion functions we don't have
zstyle ':completion:*:functions' ignored-patterns '_*'
				# expand /h/p/.pr to /home/pcp/.procmailrc
zstyle ':completion:*' expand prefix suffix
				# insert all expansions for expand completer
zstyle ':completion:*:expand:*' tag-order all-expansions

# 7.2.4. Selection Display {{{3

				# menu completion with selection
#zstyle ':completion:*' menu yes=2 no=2
# select=2 select=long-list
zstyle ':completion:*:ignored:*' single-ignored menu

# 7.2.5. Specific Commands {{{3

zstyle ':completion:*' muttrc=~/.mutt/muttrc
zstyle ':completion:*:*:kill:*' menu yes select
zstyle ':completion:*:kill:*' force-list always
zstyle ':completion:*:rm:*' ignore-line yes
zstyle ':completion:*:*:(^rm):*:*files' ignored-patterns '*?.o' '*?.~*~' \
  '*?.class' '*?.swp' '*?.obj'
zstyle ':completion:*:cd:*' tag-order local-directories path-directories

# }}}3


# 7.3. Completion Formats and Messages {{{2
# ------------------------------------

if [[ -x $(whence dircolors) && -r $HOME/.dircolors/$TERM ]]; then
  eval $(dircolors -b $HOME/.dircolors/$TERM)
fi
case $TERM in
  screen*|xterm-256color)
  list_colors=(${(s.:.)LS_COLORS} tc=7 ma=${$(tput smso)//m/} ec=${$(tput sgr0)})
  list_colors[0]="lc=${$(tput setaf)//\%*/}"
  ;;
esac
				# add colors (like ls) to completions
zstyle ':completion:*:default' list-colors $list_colors
				# listing prompt (a la less)
zstyle ':completion:*:default' list-prompt \
  "%{$bg_no_bold[blue]%}-- More -- line[%l] match[%m] page[%p]%{$reset_color%}"
				# do verbose completion output
zstyle ':completion:*' verbose 'yes'
				# format of descriptions
zstyle ':completion:*:descriptions' format "%{$fg_bold[black]%}%d%{$reset_color%}:"
				# format of messages
zstyle ':completion:*:messages' format '%d'
				# format of warn
zstyle ':completion:*:warnings' format "%{$fg_no_bold[red]%}no matches for %d%{$reset_color%}"
				# corrections
zstyle ':completion:*:corrections' format "%{$fg_bold[black]%}%d%{$reset_color%} (errors: %{$fg_no_bold[red]%}%e%{$reset_color%})"
				# give option explanation
zstyle ':completion:*:options' description 'yes'
zstyle ':completion:*:options' auto-description "specify \`%d'"
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=8=9'


# 7.4. Completion Groups {{{2
# ----------------------

				# empty group names
zstyle ':completion:*' group-name ''
				# give commands an ordering
zstyle ':completion:*:-command-' group-order builtins functions commands


# 7.5. Completion Function Usage {{{2
# ------------------------------


# 7.6. History Completion {{{2
# -----------------------

zstyle ':completion:*:history-words' stop yes
zstyle ':completion:*:history-words' remove-all-dups yes
zstyle ':completion:*:history-words' list no
zstyle ':completion:*:history-words' menu yes


# }}}2



# 8. ZLE Keybindings {{{1
# ==================


# 8.1. VI Command Mode {{{2
# --------------------

# 8.1.1. Movement {{{3

bindkey -a "t" down-line-or-history
bindkey -a "n" up-line-or-history
bindkey -a "s" vi-forward-char

# 8.1.2. Searching {{{3

bindkey -a "/" history-incremental-search-backward
bindkey -a "?" history-incremental-search-forward
bindkey -a "j" vi-find-next-char-skip
bindkey -a "J" vi-find-prev-char-skip
bindkey -a "k" vi-repeat-search
bindkey -a "K" vi-rev-repeat-search 

# 8.1.3. Change {{{3

bindkey -a "L" vi-change-whole-line
bindkey -a "T" vi-join
bindkey -a "l" vi-substitute

# 8.1.4. Miscellaneous {{{3

bindkey -a "^C" clear-screen
bindkey -a "^L" redisplay
bindkey -a "^R" redo
bindkey -a "N" run-help
bindkey -a "u" undo
bindkey -a "~" vi-oper-swap-case

# }}}3


# 8.2. VI Insert Mode {{{2
# -------------------

# 8.2.1. Completion {{{3

bindkey "^D" list-choices
bindkey "^P" _history-complete-older
bindkey "^N" _history-complete-newer

# 8.2.4. Miscellaneous {{{3

bindkey "^F" describe-key-briefly
bindkey "^C" clear-screen
bindkey "^R" redisplay
bindkey "^_" undo
bindkey "^Q" push-line-or-edit
bindkey " " magic-space
bindkey "^H" backward-delete-char
bindkey "^W" backward-kill-word

# }}}3

# 8.3. Menu-select Mode {{{2
# ---------------------

bindkey -M menuselect '^N' accept-and-infer-next-history
bindkey -M menuselect 'h' vi-backward-char
bindkey -M menuselect 't' down-line-or-history
bindkey -M menuselect 'n' up-line-or-history
bindkey -M menuselect 's' vi-forward-char
bindkey -M menuselect '^_' undo


# }}}2



# 9. Function (Auto)loading {{{1
# =========================


# 9.1. Prompt Subsystem {{{2
# ---------------------

autoload -U promptinit		# load up the prompt theme system
promptinit			# and start it up
prompt lonestar			# finally, use our awesowe theme


# }}}2



# 10. Aliases {{{1
# ===========


# 10.1. Convenience Aliases/Macros {{{2
# --------------------------------

alias v='vimless'               # run vimless for v
alias vim='vim -X'
alias view='v'                  # run vimless through v for view
alias mv='nocorrect mv'		# don't correct spelling for `mv'
alias cp='nocorrect cp'		# don't correct spelling for `cp'
alias mkdir='nocorrect mkdir'	# don't correct spelling for `mkdir'
alias d='dirs -v'		# display directory stack verbosely
alias duh='du -ch --max-depth=1'  # run `du' with human readable, short output
alias dfh='df -h'		# run `df' with human readable output
				# run `ps' with nice output format
alias p='ps --User pcp --format "pid comm" -H'
				# enable grep color output and print linenumber
alias grep='grep --color=auto -n'
alias yafc='yafc -q'            # shut up yafc
				# some cd shortcuts
alias ...='builtin cd ../..'
alias ....='builtin cd ../../..'
autoload -U cdup
				# for some reason we need to add > /dev/null
				# pushdsilent doesn't seem to work right
cd () {
  if [[ -f $1 ]]; then
    builtin cd $1:h > /dev/null
  else
    builtin cd $1 > /dev/null
  fi
}


# 10.2. ls Aliases {{{2
# ----------------

alias ls='ls --color=auto'
alias a='ls'
alias o='ls -l -h'
alias e='ls -A'
alias u='ls -A -l -h'
i () { command ls -A -l --color=always -b "$@" | ${LISTER:-less} }


# 10.4. Shell Aliases {{{2
# -------------------

				# reload all shell functions (i.e. reread its
				# definition) given as arguments.
freload () {
  while (( $# )); do
    unfunction $1
    autoload -U $1
    shift
  done
}


# 10.5. Miscellaneous Aliases {{{2
# ---------------------------

autoload zcalc

autoload zmv
alias mmv='noglob zmv -W'


# }}}2



# }}}1



# vim: set sts=2 sw=2 ts=8:


Messages sorted by: Reverse Date, Date, Thread, Author