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

Re: off topic



On Dec 9,  9:45am, Ray Andrews wrote:
} Subject: Re: off topic
}
} On 12/09/2016 08:28 AM, Oliver Kiddle wrote:
} 
} Thanks Oliver:
} > There's clear advantages to having a powerful setup that you 
} > understand well. If that process now involves "brutality" then you can 
} > understand why people might be be happy to just take what they get 
} > with oh-my-zsh: and I don't view that as heresy. Oliver 
} 
} I know I've ranted about this before, but I sure wish there was 
} something in between.

I've had the below kicking around for a while, was planning to post it
after 5.3 was out but might as well offer it for comments.  This is
mostly specific to completion; it collects what I think are a set of
sensible default settings to make completion "pretty" and informative
without adding so many special-cases that the user gets lost.

It's also designed to be source-able at any point either before or
after the user's own zstyles without stomping on anything.

Some of these are pulled directly from examples in the manual, some
from zsh-newuser-install, others from various suggestions that have
gone by on the mailing lists, etc.

--- 8< --- 8< --- 8< ---
# Safely define default values for assorted completion zstyles

emulate zsh -o extendedglob -c 'default_zstyle() {
  local -a patstyle defn
  if [[ "$1" = (-e|-|--) ]]
  then patstyle=( "$2" "$3" )
  else patstyle=( "$1" "$2" )
  fi
  zstyle -g defn "${patstyle[@]}" || zstyle "$@"
}'

###

autoload -Uz colors && colors

###

default_zstyle ':completion:*' completer \
    _expand _complete _ignored _correct _approximate

# General appearance
default_zstyle ':completion:*' menu 'yes=long' 'select=long-list'
default_zstyle ':completion:*' group-name ''
default_zstyle ':completion:*' verbose true
default_zstyle ':completion:*' ignore-parents parent pwd ..
default_zstyle ':completion:*' format '%BCompleting %U%d%u%b'
default_zstyle ':completion:*:messages' format %S%d%s
default_zstyle ':completion:*:warnings' format 'No matches for %U%d%u'
default_zstyle ':completion:*:corrections' format \
     '%BCompleting %U%d%u (errors: %e)%b'

# Insert all expansions for expand completer
default_zstyle ':completion:*:expand:*' tag-order all-expansions

# Allow one error for every three characters typed for _approximate
default_zstyle -e ':completion:*:approximate:*' max-errors \
    'reply=( $(( ($#PREFIX+$#SUFFIX)/3 )) numeric )'
# Allow two errors elsewhere, e.g. for _correct
default_zstyle ':completion:*' max-errors 2 numeric

# Double colon here to avoid overriding the value set by "zed"
default_zstyle ':completion::*' insert-tab 'pending=1'

# Matching
# 1. Try completion with no alterations (i.e., literal match is best)
# 2. Match substrings separated by dashes, dots, underscores, commas
# 3. As (2) but case-insensitively
# 4. As (2) but allow arbitrary stuff at the beginning of the result
default_zstyle ':completion:*' matcher-list '' 'r:|[-._,]=** r:|=**' \
    'm:{[:lower:][:upper:]}={[:upper:][:lower:]} r:|[-._,]=** r:|=**' \
    'r:|[-._,]=** r:|=** l:|=*'

# Offer indexes before parameters in subscripts
default_zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters

# Ignore completion functions (until the _ignored completer)
zstyle ':completion:*:functions' ignored-patterns '_*'

# From Oliver Kiddle, users/20372, for process lists
default_zstyle ':completion:*:(kill|lsof|ps|ss):*:' tag-order \
	processes:-tty 'processes:-mine:user\ processes' \
	'processes:-all:all\ processes'
default_zstyle ':completion:*:([sl]trace|truss|gcore|(ll|g)db):*:' tag-order \
	processes:-mine 'processes:-all:all\ processes'
case $OSTYPE in
  *bsd*)
    default_zstyle ':completion:*:processes' command \
	'ps -o pid,ppid,state,start,args'
    default_zstyle ':completion:*:processes-mine' command \
	"ps U $EUID -o pid,ppid,state,start,args"
    default_zstyle ':completion:*:processes-all' command \
	"ps A -o pid,ppid,state,start,args"
  ;;
  *)
    default_zstyle ':completion:*:processes' command \
	'ps -o pid,s,ppid,stime,args'
    default_zstyle ':completion:*:processes-mine' command \
	"ps -u $EUID -o pid,s,ppid,stime,args"
    default_zstyle ':completion:*:processes-all' command \
	'ps -e -o pid,s,ppid,stime,args'
  ;;
esac

# Avoid subverting list-colors, otherwise show-ambiguity reverse-video
default_zstyle -e ':completion:(#b)(*)' show-ambiguity \
    'zstyle -T ":completion:$match" list-colors && reply=( ${color[reverse]} )'



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