diff options
Diffstat (limited to 'debian/examples')
-rw-r--r-- | debian/examples/carstenh.zshrc | 392 | ||||
-rw-r--r-- | debian/examples/old/compctl.dpkg | 92 | ||||
-rw-r--r-- | debian/examples/old/jhm.zshrc | 516 | ||||
-rw-r--r-- | debian/examples/ssh_completion | 66 | ||||
-rw-r--r-- | debian/examples/ssh_completion2 | 37 |
5 files changed, 1103 insertions, 0 deletions
diff --git a/debian/examples/carstenh.zshrc b/debian/examples/carstenh.zshrc new file mode 100644 index 000000000..d8a018625 --- /dev/null +++ b/debian/examples/carstenh.zshrc @@ -0,0 +1,392 @@ +# ~/.zshrc file for zsh(1). +# +# This file is sourced only for interactive shells. It should contain +# commands to set up aliases, functions, options, key bindings, etc. +# +# Global Order: zshenv, zprofile, zshrc, zlogin +# +# To enable the below-mentioned features uncomment the according lines. + + +# ### Include user name, host name and current working directory in the prompt: +PS1='%(!..%n@)%m:%~%# ' + +# ### Select emacs like key bindings: +# bindkey -e + +# ### Define some useful aliases: +# { ls --help | grep -- --color } >/dev/null 2>&1 && alias ls='ls --color=auto' +# alias l='ls -F' +# alias ll='ls -F -l' +# alias la='ls -F -A' + +# ### Keep 1000 lines of history within the shell and save it to ~/.zsh_history: +# HISTSIZE=1000 +# SAVEHIST=1000 +# HISTFILE=~/.zsh_history + +# ### Teach less, e.g., reading compressed files and listing archive content: +# which lesspipe >/dev/null && eval "$(lesspipe)" + +# ### Turn on completion with the default options: +# autoload -Uz compinit; compinit +# ### Enable completion menu: +# zstyle ':completion:*' menu select=2 +# ### Activate colored completion: +# which dircolors >/dev/null && eval "$(dircolors -b)" +# zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} + +# ### If we are in a Debian chroot display its name in the prompt: +# [[ -r /etc/debian_chroot ]] && : ${debian_chroot:="$(cat /etc/debian_chroot)"} +# PS1="${debian_chroot:+($debian_chroot)}%(!..%n@)%m:%~%# " + +# ### Use vcs_info to include version control system information in the prompt: +# setopt prompt_subst +# autoload -Uz vcs_info; vcs_info 2>/dev/null && precmd() { vcs_info } +# PS1="${debian_chroot:+($debian_chroot)}%(!..%n@)%m:%~\${vcs_info_msg_0_}%# " +# ### Configure vcs_info to be colorful: +# zstyle ':vcs_info:*' actionformats ' %F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f ' +# zstyle ':vcs_info:*' formats ' %F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{5}]%f ' +# zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r' + + + +# ### ######################################################################## +# ### All features below this line are disabled, uncomment the according # +# ### lines to enable them. # +# ### ######################################################################## + +# ### Content: +# ### * Environment variables: +# ### - LESS: Set default options for less. +# ### - GIT_PAGER: Set pager used by git. +# ### - GIT_EXEC_PATH: Tell git to look in ~/bin/git for git executables. +# ### - TIMEFMT: Set outputformat of shell builtin time. +# ### * Zsh options: +# ### - Not listed here. +# ### * Precmd / preexec: +# ### - Set xterm / rxvt title. +# ### - Set screen's window title. +# ### - Transparent directory replacement. +# ### * Aliases: +# ### - Not listed here. +# ### * Functions: +# ### - Start(), Restart(), Stop(), Reload(), Force-Reload(): +# ### Start, restart, stop, reload or force-reload a System-V +# ### style init script. +# ### - accessed(), changed(), modified(): +# ### List files which have been changed / modified / accessed +# ### within the last n days, n defaults to 1. +# ### - accessed.(), changed.(), modified.(): +# ### Same as above, but list files whose name start with +# ### a dot. +# ### - bk(): Make a backup of a file. +# ### - cdt(): Create temporary directory and chdir into it. +# ### - edalias(): Edit an alias via zle. +# ### - edfunc(): Edit a function via zle. +# ### - md(): Create given directory recursively and chdir into it. +# ### - sll(): List symlinks in detail (more detailed 'readlink -f'). +# ### - unik(): Print unique lines, input does not need to be sorted. +# ### * Misc: +# ### - Chdir to ~ if zsh was started in a non-existent directory. +# ### - Cat ~/dead.letter. +# ### - Source ~/.zshrc.local if it exists and is readable. + + + +# ### ######################################################################## +# ### Environment variables: # +# ### ####################################################################{{{1 + +# ### Set default options for less: +# ### -~ -- Display lines after end of file as blank lines. +# ### -# -- Specifies the default number of positions to scroll horizontally +# ### in the RIGHTARROW and LEFTARROW commands. +# ### -K -- Causes less to exit immediately when ^C is typed. +# ### -M -- Causes less to prompt even more verbosely than more. +# ### -R -- Causes ANSI "color" escape sequences to be displayed. +# ### -i -- Causes searches to ignore case like vim's smartcase does. +# ### -q -- Use visual bell but not the terminal bell. +# ### -w -- Temporarily highlight the first "new" line after a forward movement. +# which less >/dev/null && export LESS='-~#20KMRiqw' + +# ### Set pager used by git: +# ### -E -- Automatically exit the first time it reaches end-of-file. +# ### -F -- Automatically exit if the entire file fits on the first screen. +# ### -X -- Disable sending the termcap initialization and deinitialization +# ### strings to the terminal. Prevents clearing the screen. +# which less >/dev/null && export GIT_PAGER='less -EFX' + +# ### Tell git to look in ~/bin/git for git executables: +# which git >/dev/null && export GIT_EXEC_PATH="`git --exec-path`:$HOME/bin/git" + +# ### Set outputformat of shell builtin time: +# TIMEFMT=" +# Time spent in user mode: %U +# Time spent in kernel mode: %S +# Total time: %E +# CPU utilisation: %P +# " + + +# ### #####################################################################}}} +# ### Zsh options: # +# ### ####################################################################{{{1 + +# ### Changing directories: +# ### Try chdir if there is no matching executeable. +# setopt autocd +# ### Chdir to hashed directories without the need to prepend ~. +# setopt cdablevars +# ### Make cd push the old directory onto the directory stack. +# setopt autopushd +# ### Don't push multiple copies of the same directory onto the stack. +# setopt pushdignoredups +# ### Do not print the directory stack after pushd or popd. +# setopt pushdsilent +# ### Make pushd with no arguments act like `pushd $HOME'. +# setopt pushdtohome + +# ### Completion: +# ### Use different widths whilst displaying completion menu to reduce size. +# setopt listpacked +# ### Try to complete when cursor is in the word. +# setopt complete_in_word +# ### Automatically list choices on an ambiguous completion. +# setopt autolist + +# ### History: +# ### Don't display duplicates in while searching in history. +# setopt histfindnodups +# ### Don't put duplicate lines in history. +# setopt histignoredups +# ### Remove superfluous blanks from history. +# setopt histreduceblanks +# ### Reload line into editing buffer instead of executing it. +# setopt histverify +# ### Don't add lines prefixed by a space to history. +# setopt histignorespace + +# ### Job Control: +# ### Don't nice backgrounded jobs. +# setopt nobgnice +# ### Don't send HUP signal to running jobs when the shell exists and don't +# ### complain about still running background jobs. +# setopt nohup nocheckjobs +# ### Print backgrounded jobs when they finish. +# setopt notify +# ### Disable flow-control with ^S and ^Q. +# setopt noflowcontrol + +# ### Prompt: +# ### Print exitvalues != 0. +# setopt printexitvalue +# ### Send \r on new line. +# setopt promptcr + +# ### Zle: +# ### Be quiet. +# setopt nobeep + + +# ### #####################################################################}}} +# ### Precmd / preexec: # +# ### ####################################################################{{{1 + +# ### Set xterm / rxvt title: +# preexec_xterm_title() { +# [[ "$TERM" != "xterm" ]] && [[ "$TERM" == "${TERM#rxvt}" ]] && return +# print -nR $'\033]0;'$1$'\a' +# } +# precmd_xterm_title() { +# [[ "$TERM" != "xterm" ]] && [[ "$TERM" == "${TERM#rxvt}" ]] && return +# print -nR $'\033]0;'Terminal$'\a' +# } +# preexec_functions=( ${preexec_functions} preexec_xterm_title ) +# precmd_functions=( ${precmd_functions} precmd_xterm_title ) + +# ### Set screen's window title: +# preexec_screen_window_title() { +# [[ "$TERM" == "${TERM#screen}" ]] && return +# setopt localoptions extendedglob shwordsplit noksharrays +# typeset -a cmd m_bracket m_brace m_paren m_percent +# cmd=(${${1}[(wr)^(*=*|nice|sudo|time|env|fakeroot|trickle|-*),-1]}) +# [[ -n "$cmd[2]" ]] || { echo -ne "\ek$cmd[1]\e\\"; return; } +# m_bracket=( vi vim emacs mcedit nano ee joe less more most ) +# m_percent=( make ) +# m_paren=( man perldoc ) +# m_brace=( ) +# local cmd1="$cmd[1]" m1 m2 +# if { [[ ${m_bracket[(i)$cmd1]} -le ${#m_bracket} ]] && m1='[' && m2=']' } \ +# || { [[ ${m_brace[(i)$cmd1]} -le ${#m_brace} ]] && m1='{' && m2='}' } \ +# || { [[ ${m_paren[(i)$cmd1]} -le ${#m_paren} ]] && m1='(' && m2=')' } \ +# || { [[ ${m_percent[(i)$cmd1]} -le ${#m_percent} ]] && m1='%' && m2='%' } +# then +# shift 1 cmd +# cmd=(${${cmd}[(wr)^(*=*|-*|1|2|3|4|5|6|7|8),-1]}) +# cmd[1]="${${${${cmd[1]}##*/}%=}:-$cmd1}" +# fi +# echo -ne "\ek$m1$cmd[1]$m2\e\\" +# } +# precmd_screen_window_title() { +# [[ "$TERM" == "${TERM#screen}" ]] && return +# echo -ne "\ekzsh\e\\" +# } +# preexec_functions=( ${preexec_functions} preexec_screen_window_title ) +# precmd_functions=( ${precmd_functions} precmd_screen_window_title ) + +# ### Transparent directory replacement: +# ### http://chris-lamb.co.uk/2009/11/19/transparent-directory-replacement-zsh/ +# precmd_transparent_dir_replacement() { +# [ . -ef "$PWD" ] && return 0 +# local OLDOLDPWD="$OLDPWD" +# builtin cd -q -- "$PWD" >/dev/null 2>&1 || { +# echo >&2 "W: $PWD does not exist anymore." +# return 1 +# } +# OLDPWD="$OLDOLDPWD" +# } +# precmd_functions=( ${precmd_functions} precmd_transparent_dir_replacement ) + + +# ### #####################################################################}}} +# ### Aliases: # +# ### ####################################################################{{{1 + +# ### Ordinary aliases: +# { grep --help | grep -- --color } >/dev/null 2>&1 && \ +# alias grep='grep --color=auto' +# { egrep --help | grep -- --color } >/dev/null 2>&1 && \ +# alias egrep='egrep --color=auto' +# alias cp='nocorrect cp' +# alias ln='nocorrect ln' +# alias mkdir='nocorrect mkdir' +# alias mv='nocorrect mv' +# alias rm='nocorrect rm' + +# ### Suffix aliases: +# ### http://dev.codemac.net/config.git?p=config.git;a=blob;f=zsh/alias +# ### Automatically open images: +# if which feh >/dev/null; then +# alias -s {jpg,JPG,jpeg,JPEG,png,PNG,gif,GIF}="feh -FZd" +# fi +# ### Automatically open movies: +# if which mplayer >/dev/null; then +# alias -s {mpg,mpeg,avi,ogm,wmv,m4v,mp4,mov,3GP}="mplayer -idx" +# fi +# ### Automatically open web addresses (requires $BROWSER to be set): +# if [[ -n "$BROWSER" ]] && which "$BROWSER" >/dev/null; then +# alias -s {html,htm,com,net,org,gov,edu,de}="$BROWSER" +# fi +# ### Automatically open text files (requires $EDITOR to be set): +# if [[ -n "$EDITOR" ]] && which "$EDITOR" >/dev/null; then +# alias -s {txt,c,h}="$EDITOR" +# fi +# ### Automatically open other known files: +# which evince >/dev/null && alias -s pdf="evince" +# which evince >/dev/null && alias -s ps="evince" +# which java >/dev/null && alias -s jar="java -jar" + + +# ### #####################################################################}}} +# ### Functions: # +# ### ####################################################################{{{1 + +# ### Start(), Restart(), Stop(), Reload(), Force-Reload(): +# ### Start, restart, stop, reload or force-reload a System-V +# ### style init script. +# eval {Start,Restart,Stop,Reload,Force-Reload}'() { ( +# builtin cd -q / || { echo >&2 "E: Could not chdir to /"; return 1; } +# env -i PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \ +# "/etc/init.d/${1:?}" "${0:l}" +# ) };' +# compctl -g "/etc/init.d/*(:t)" Start Restart Stop Reload Force-Reload + +# ### accessed(), changed(), modified(): +# ### List files which have been changed / modified / accessed +# ### within the last n days, n defaults to 1. +# accessed() { emulate -L zsh; print -l -- *(a-${1:-1}); } +# changed() { emulate -L zsh; print -l -- *(c-${1:-1}); } +# modified() { emulate -L zsh; print -l -- *(m-${1:-1}); } +# ### accessed.(), changed.(), modified.(): +# ### Same as above, but list files whose name starts with +# ### a dot. +# accessed.() { emulate -L zsh; print -l -- .*(a-${1:-1}); } +# changed.() { emulate -L zsh; print -l -- .*(c-${1:-1}); } +# modified.() { emulate -L zsh; print -l -- .*(m-${1:-1}); } + +# ### bk(): Make a backup of a file. +# bk() { +# cp -a "$1" "${1}_$(date --iso-8601=seconds)"; +# } + +# ### cdt(): Create temporary directory and chdir into it. +# cdt() { +# [[ $# -eq 0 ]] || printf 'Usage: %s\n' "$0"; +# builtin cd "$(mktemp -t -d cdt.XXXXXXXXXX)"; +# } + +# ### edalias(): Edit an alias via zle. +# edalias() { +# [[ -z "$1" ]] && { echo "Usage: edalias <alias_to_edit>" ; return 1 } +# vared aliases'[$1]' +# } +# compdef _aliases edalias + +# ### edfunc(): Edit a function via zle. +# edfunc() { +# [[ -z "$1" ]] && { echo "Usage: edfun <function_to_edit>" ; return 1 } +# zed -f "$1" +# } +# compdef _functions edfunc + +# ### md(): Create given directory recursively and chdir into it. +# md() { +# [[ $# -eq 1 ]] || printf 'Usage: %s <directory>\n' "$0"; +# mkdir -p "$1" && builtin cd "$1"; +# } +# compdef md=mkdir + +# ### sll(): List symlinks in detail (more detailed 'readlink -f'). +# sll() { +# [[ -z "$1" ]] && printf 'Usage: %s <file(s)>\n' "$0" && return 1 +# local file +# for file in "$@"; do +# ( +# while [[ -h "$file" ]]; do +# ls -l "$file" +# builtin cd -q "${file:h}" +# file="$(readlink "${file:t}")" +# done +# ls -l "$file" +# ) +# done +# } + +# ### unik(): Print unique lines, input does not need to be sorted. +# unik() { +# perl -ne 'print unless $seen{$_}++' "$@" +# } + + +# ### #####################################################################}}} +# ### Misc: # +# ### ####################################################################{{{1 + +# ### Chdir to ~ if zsh was started in a non-existent directory: +# [[ "$PWD" == . ]] && builtin cd ~ + +# ### Cat ~/dead.letter: +# if [[ -r ~/dead.letter ]]; then +# echo ~/dead.letter: +# cat ~/dead.letter +# echo +# fi +# if [[ "$USERNAME" == root ]] && [[ -r /dead.letter ]]; then +# echo /dead.letter: +# cat /dead.letter +# echo +# fi + +# ### Source ~/.zshrc.local if it exists and is readable: +# [[ -r ~/.zshrc.local ]] && . ~/.zshrc.local || true diff --git a/debian/examples/old/compctl.dpkg b/debian/examples/old/compctl.dpkg new file mode 100644 index 000000000..d8c142e28 --- /dev/null +++ b/debian/examples/old/compctl.dpkg @@ -0,0 +1,92 @@ +############################################################################# +# Dpkg completion control for zsh. +# +# NOTE: Completion for these commands (dpkg, dpkg-source, bug) +# are included # upstream as part of the new completion system. +# Seriously consider using that instead. +# +# Originally by Joey Hess <joey@kite.ml.org>, GPL copyright. +# Contributions and fixes from Karl Hegbloom, Fabien Ninoles, +# Gregor Hoffleit, Csaba Benedek, &c. +# +# Currently doesn't handle correctly: +# Options after -D or --debug. +# --force- and friends,--ignore-depends,--root= and friends. + +# A function to return all available package names. +# This could be done without grep and awk by replacing that line with +# reply=(${${(M)${(f)"$(</var/lib/dpkg/status)"}:#Package:*}#Package: }) +function DpkgPackages { + reply=(`grep '^Package:' /var/lib/dpkg/status | awk '{ print $2 }'`) +} + +# This array lists all the dpkg options and actions. +dpkg_options=(-i --install --unpack --configure -r --remove --purge -A \ +--avail --update-avail --merge-avail --yet-to-unpack -l --list -L \ +--listfiles -C --audit -S --search -s --status --help -c --contents -I \ +--info -B --auto-deconfigure -D --debug --largemem --smallmem --no-act \ +-R --recursive -G -O --selected-only -E -e --control --skip-same-version \ +-x --extract -f --field --fsys-tarfile -X --vextract --licence --version \ +-b --build) + +# This string lists all dpkg actions that operate on *.deb files, +# separated by |'s. There can't be any extra whitespace in it! +dpkg_deb_actions="-i|--install|--unpack|-A|--avail|-c|--contents|-I|--info|-e" +dpkg_deb_actions="$dpkg_deb_actions|--control|-x|--extract|-f|--field" +dpkg_deb_actions="$dpkg_deb_actions|--fsys-tarfile|-X|--vextract|-info" + +# This string lists all dpkg actions that normally operate on *.deb files, +# but can operate on directory names if the --recursive option is given to +# dpkg. +dpkg_deb_rec_actions="-i|--install|--unpack|-A|--avail" + +# This string lists all other dpkg actions that take a directory name as +# their first parameter, and a filename as their second parameter. +dpkg_df_actions="-b|--build" + +# This string lists dpkg actions that take a directory name as +# their second parameter. +dpkg_dir2_actions="-e|--control|-x|--extract|--vextract" + +# This string lists all dpkg actions that take a filename as their first +# parameter (ie, a Packages file). +dpkg_file_actions="-S|--search|--update-avail|--merge-avail" + +# This string lists all dpkg actions that operate on the names of packages +# and can also be used with the --pending option. +dpkg_pkg_pending_actions="--configure|-r|--remove|--purge|-s|--status" + +# This string lists all other dpkg actions that operate on the names of +# packages. +dpkg_pkg_actions="-L|--listfiles|-s|--status|-l|--list" + +# Now the command that puts it all together.. +compctl -k dpkg_options \ + -x "C[-1,$dpkg_deb_rec_actions],R[-R|--recursive,]" -g '*(-/D)' \ + - "C[-1,$dpkg_deb_actions]" -g '*.deb' + -g '*(-/D)' \ + - "C[-1,$dpkg_pkg_pending_actions]" -K DpkgPackages + -k "(-a,--pending)" \ + - "C[-1,$dpkg_pkg_actions]" -K DpkgPackages \ + - "C[-1,$dpkg_file_actions],C[-2,$dpkg_df_actions]" -f \ + - "C[-2,$dpkg_dir2_actions],C[-1,$dpkg_df_actions]" -g '*(-/D)' \ + -- dpkg + +# Also, set up package name completion for bug program. +compctl -K DpkgPackages bug + +# This section by Karl M. Hegbloom + +dpkg_source_options=(-x -b -c -l -F -V -T -D -U \ +-sa -sk -sp -su -sr -ss -sn -sA -sK -sP -sU -sR \ +-h --help) + +compctl -k dpkg_source_options \ + -x "C[-1,-x]" -g '*.dsc' \ + - "C[-1,-b]" -g '*(-/D)' \ + -- dpkg-source + +# Unset the temporary variables. +unset dpkg_deb_actions dpkg_deb_rec_actions dpkg_df_actions \ + dpkg_dir2_actions dpkg_file_actions dpkg_pkg_pending_actions \ + dpkg_pkg_actions # dpkg_source_options dpkg_options + +############################################################################# diff --git a/debian/examples/old/jhm.zshrc b/debian/examples/old/jhm.zshrc new file mode 100644 index 000000000..86dacc7eb --- /dev/null +++ b/debian/examples/old/jhm.zshrc @@ -0,0 +1,516 @@ +# Ray's .zshrc +# Note that completions for dpkg-deb, mutt, mount, and dupload are +# included as part of the new completion system. See docs for details. + +# Zsh settings + +# TODO +# - completions for dpkg-deb +# - completions for lintian +# - completions for dupload +# - completions for nm +# - completions for objdump +# - completions for mount +# - completion for man -l + +bindkey -e # Emacs-style commandline editing + +case "$TERM" in + linux) # Linux console + bindkey '\e[1~' beginning-of-line # Home + bindkey '\e[4~' end-of-line # End + bindkey '\e[3~' delete-char # Del + bindkey '\e[2~' overwrite-mode # Insert +# bindkey '\e[A' up-line-or-history # cursor up +# bindkey '\e[B' down-line-or-history # cursor down +# bindkey '\e[C' forward-char # cursor right +# bindkey '\e[D' backward-char # cursor left + ;; + screen) # The textmode window manager + # In Linux console + bindkey '\e[1~' beginning-of-line # Home + bindkey '\e[4~' end-of-line # End + bindkey '\e[3~' delete-char # Del + bindkey '\e[2~' overwrite-mode # Insert + bindkey '\e[7~' beginning-of-line # home + bindkey '\e[8~' end-of-line # end + # In rxvt + bindkey '\eOc' forward-word # ctrl cursor right + bindkey '\eOd' backward-word # ctrl cursor left + bindkey '\e[3~' backward-delete-char # This should not be necessary! +# bindkey '\e[A' up-line-or-history # cursor up +# bindkey '\e[B' down-line-or-history # cursor down +# bindkey '\e[C' forward-char # cursor right +# bindkey '\e[D' backward-char # cursor left + ;; + rxvt) + bindkey '\e[7~' beginning-of-line # home + bindkey '\e[8~' end-of-line # end + bindkey '\eOc' forward-word # ctrl cursor right + bindkey '\eOd' backward-word # ctrl cursor left + bindkey '\e[3~' backward-delete-char # This should not be necessary! + bindkey '\e[2~' overwrite-mode # Insert + ;; + xterm*) + bindkey '\e[H' beginning-of-line # Home + bindkey '\e[F' end-of-line # End + bindkey '\e[3~' delete-char # Del + bindkey '\e[2~' overwrite-mode # Insert + ;; + sun) + bindkey '\e[214z' beginning-of-line # Home + bindkey '\e[220z' end-of-line # End + bindkey '^J' delete-char # Del + bindkey '^H' backward-delete-char # Backspace + bindkey '\e[247z' overwrite-mode # Insert + ;; +esac + +#if test "X$TERM" = "Xscreen" || test "X$TERM" = "Xlinux"; then +# bindkey '\e[A' up-line-or-history # cursor up +# bindkey '\e[B' down-line-or-history # cursor down +# bindkey '\e[C' forward-char # cursor right +# bindkey '\e[D' backward-char # cursor left +#fi +# +#if test "X$TERM" = "Xscreen" || test "X$TERM" = "Xrxvt"; then +# bindkey '\e[7~' beginning-of-line # home +# bindkey '\e[8~' end-of-line # end +# bindkey '\eOc' forward-word # ctrl cursor right +# bindkey '\eOd' backward-word # ctrl cursor left +# bindkey '\e[3~' backward-delete-char # This should not be necessary! +#fi + +export DEBEMAIL=jhm@cistron.nl +export IRCNICK=JHM +export IRCSERVER=irc.nl.openprojects.org +eval `lesspipe` + +alias glimpse='glimpse -z -i -w' + +# All functions used for defining completion rules start with `c_'. +setopt extendedglob # required for some of our completion magic +setopt list_types # Put a file type indicator after file names when + # completing. +setopt correct # Attempt spelling correction on command names only. +setopt print_exit_value +setopt list_ambiguous +setopt bash_auto_list # Make <tab><tab> do the right thing. +setopt list_packed # Compacter display of completion list. +setopt interactive_comments +setopt nohup # So backgrounded jobs don't get terminated when + # the shell is. + +# A sensible prompt: +# hostname username(underlined) time pwd(bold; max 30 chars.) > or # +if test "X$TERM" = "Xscreen"; then + # include a hint that screen(1) can use to set window titles. + PROMPT='%m %U%n%u %T %B%30<..<%~%b %{[0000mk\%}%(!.#.>) ' +else + # We don't include the hint outside screen, as it causes problems + # with xterm + PROMPT='%m %U%n%u %T %B%30<..<%~%b %(!.#.>) ' +fi + +c_groups=( $(cut -d: -f1 /etc/group) ) + +############################################################################ +# Shell builtins + +compctl -k '( )' pushln +compctl -z -P '%' bg +compctl -j -P '%' fg jobs disown +compctl -j -P '%' + -s '`ps -x | tail +2 | cut -c1-5`' wait + +compctl -A shift +compctl -caF type whence which +compctl -c unhash +compctl -F functions unfunction +compctl -x 'w[1,-d] p[2]' -n - 'w[1,-d] p[3]' -g '*(-/)' - \ + 'p[1]' -c - 'p[2]' -g '*(-x)' -- hash +compctl -a unalias +compctl -v getln getopts read unset vared +compctl -v -S '=' -q declare export integer local readonly typeset +compctl -e disable +compctl -d enable + +eval compctl -k "'("`limit | cut -d\ -f1`")'" limit unlimit + +compctl -l '' -x 'p[1]' -f -- . source +compctl -s '`unsetopt`' setopt +# Redirection below makes zsh silent when completing unsetopt xtrace +compctl -s '`setopt 2> /dev/null`' unsetopt +compctl -s '${^fpath}/*(N:t)' autoload + +compctl -b bindkey +compctl -c -x 'C[-1,-*k]' -A - 'C[-1,-*K]' -F -- compctl +compctl -x 'C[-1,-*e]' -c - 'C[-1,-[ARWI]##]' -f -- fc +compctl -x 'p[1]' - 'p[2,-1]' -l '' -- sched +compctl -x 'C[-1,[+-]o]' -o - 'c[-1,-A]' -A -- set + +# Anything after nohup is a command by itself with its own completion +compctl -l '' nohup exec nice eval sudo fakeroot +compctl -x 'p[1]' -c - 'p[2,-1]' -k signals -- trap +compctl -l '' -x 'p[1]' -B -- builtin + +# kill takes signal names as the first argument after -, but job names after % +# or PIDs as a last resort +compctl -j -P '%' + -s '`ps -x | tail +2 | cut -c1-5`' + \ + -x 's[-] p[1]' -k "($signals[1,-3])" -- kill + + +############################################################################ +# Basic commands and file manipulation commands + +compctl -k '( )' pwd +compctl -g '*(/)' cd +compctl -g '^*.(c|cc|C|cxx|cpp|h|in|l|y|tex)' rm +compctl -g '*(/)' rmdir +compctl -g '*.Z' + -g '*(/)' znew +compctl -s '$(groups)' + -k groups newgrp +compctl -f -x 'p[1], p[2] C[-1,-*]' -k groups -- chgrp +compctl -f -x 'p[1] n[-1,.], p[2] C[-1,-*] n[-1,.]' -k groups \ + - 'p[1], p[2] C[-1,-*]' -u -S '.' -- chown + +# GNU ls, dir: complete files, options (both - and -- kind), and option params. +compctl -f \ + -x s'[--format]' -P '=' -k '(long verbose commas horizontal across vertical si +ngle-column)' \ + - s'[--sort]' -P '=' -k '(none time size extension)' \ + - s'[--time]' -P '=' -k '(atime ctime access use status)' \ + - s'[--width=][--tabsize=][--ignore=][-w][-T][-I],c[-1,-w][-1,-T][-1,-I]' \ + -k '( )' \ + - s'[--]' -S '' -k '(all\ escape\ directory\ inode\ kilobytes\ numeric-uid-gid\ no-group\ hide-control-chars\ reverse\ size\ width= tabsize= almost-all\ ignore-backups\ classify\ file-type\ full-time\ ignore= dereference\ literal\ quote-name\ dired\ no-color\ 7bit\ 8bit\ recursive\ sort= format= time= no-group\ help\ version\ )' \ + - s'[-]' -k '(a b c d f g i k l m n o p q r s t u x A B C F G L N Q R S U X 1 +w T I)' \ + -- ls dir + + +# Debian tar: viewing/extracting gzipped/compressed/bzip2ed/normal tar archives. +compctl -f -x \ + 'C[-1,*[xt]*f*z*] p[2]' -g '*.tar.gz *.tar.Z *.tgz' + -g '*(/)' - \ + 'C[-1,*[xt]*f*I*] p[2]' -g '*.tar.bz *.tar.bz2 *.tbz' + -g '*(/)' - \ + 'C[-1,*[xt]*f*] p[2]' -g '*.tar' -- \ + + -g '*(/)' tar + +## tar: complete tar files (only .tar or .tar.* format) after -f, disable +## completion for certain options, let user choose directory with -C, +## complete GNU tar long options beginning with --. The match-taropts +## function prompts for GNU tar options, ensures one of the seven +## mandatory options is given in the first argument to tar, and enforces +## spaces after options that take an argument (this is required by GNU +## tar and also makes filename completion possible for the -f option). +## Note that the -[0-7][lmh] options are not completed, but they're +## hardly ever used. +#compctl -f \ +# -x 'C[-1,-*f],p[2] C[-1,*f],c[-1,--file]' -g '*.tar(|.*)' + -g '*(-/)' \ +# - 'C[-1,-*[bLN]],p[2] C[-1,*[bLN]],c[-1,--block-size][-1,tape-length][-1,--after-date][-1,--newer]' -k '( )' \ +# - 'C[-1,-*C],p[2] C[-1,*C],c[-1,directory]' -g '*(-/)' \ +# - 'C[-1,-*[FgKTV]],p[2] C[-1,*[FgKTV]],c[-1,--info-script][-1,--new-volume-script][-1,--starting-file][-1,--files-from][-1,--label][-1,--exclude]' -f \ +# - 's[--]' -k '(catenate concatenate create diff compare delete append list update extract get atime-preserve block-size read-full-blocks directory checkpoint file force-local info-script new-volume-script incremental dereference ignore-zeros ignore-failed-read keep-old-files starting-file one-file-system tape-length modification-time multi-volume after-date newer old-archive portability to-stdout same-permissions preserve-permissions absolute-paths preserve record-number remove-files same-order preserve-order same-owner sparse files-from null totals verbose label version interactive confirmation verify exclude exclude-from compress uncompress gzip ungzip use-compress-program block-compress)' \ +# - 's[-],p[1]' -S '' -K 'match-taropts' \ +# -- tar + +# GNU find. +# Note that 'r[-exec,;]' must come first. +# We hardwire the filesystem types rather than use /proc/filesystems, in order +# not to exclude filesystems that are supported through modules that are +# currently not loaded. +compctl -x 'r[-exec,;][-ok,;]' -l '' - \ +'s[-]' -s 'daystart {max,min,}depth follow noleaf version xdev mount \ + {a,c,}newer {a,c,m}{min,time} empty false {fs,x,}type {u,g}id inum \ + links {i,}{l,}name {no,}{user,group} {i,}path perm {i,}regex size \ + true used exec {f,}print{f,0,} ok prune {f,}ls or not and' - \ +'p[1]' -g '. .. *(-/)' - \ +'C[-1,-((a|c|)newer|fprint(|0|f))]' -f - \ +'c[-1,-fstype]' -k '(ext2 fat iso9660 minix nfs vfat)' - \ +'c[-1,-type]' -k '(b c d p f l s)' -X '[b]lock dev, [c]har dev, [d]ir, named [p]ipe, regular [f]ile, [s]ocket' - \ +'c[-1,-size]' -k '(1234c 567k)' -X '512-byte [b]locks, [c] bytes, [k]ilobytes, 2-byte [w]ords' - \ +'c[-1,-group]' -k c_groups - \ +'c[-1,-user]' -u -- find + + +############################################################################ +# Commands that are usually used on non-generated files. + +compctl -g '*.gz *.Z *.bz2' \ + + -g '*.web *.docbook' \ + + -g '*.c *.cc *.C *.cxx *.cpp *.h *.tex *.txt *.html' \ + + -g '^*.(o|a|so|aux|dvi|log|swp|fig|bbl|blg|bst|idx|ind|out|toc)' \ + + -g '.*' \ + + -g '*(/)' vi vim gvim less grep zgrep + +############################################################################ +# Mail +# TODO: mutt + +############################################################################ +# Document processing + +compctl -g '*.tex' + -g '*(/)' tex +compctl -g '*.tex *.ltx' + -g '*(/)' {latex,pdflatex} +compctl -g '*.texi' + -g '*(/)' texi2{dvi,pdf,html} + +function c_bibtex { + reply=(`ls *.aux | sed -e 's/\.aux//'`); +} +compctl -K c_bibtex bibtex + + +############################################################################ +# Viewers, editors etc. + +compctl -g '*.gz *.Z' + -g '*(/)' zcat gunzip gzcat zless +compctl -g '*.bz *.bz2' + -g '*(/)' bzcat bz2cat bunzip2 +compctl -g '*.ps *.ps.gz *.pdf *.pdf.gz *.eps *.eps.gz' + -g '*(/)' gv +compctl -g '*.(e|)ps' + -g '*(-/)' gs ghostview ps2ascii ps2text psnup ps2pdf +compctl -g '*.pdf' + -g '*(/)' acroread xpdf +compctl -g '*.dvi *.dvi.gz' + -g '*(/)' xdvi +compctl -g '*.dvi' + -g '*(/)' dvi2fax dvidvi dvilj dvilj4 dvips dvitomp \ + dvicopydvihp dvilj2p dvilj4l dvired dvitype +compctl -g '*.html' + -g '*.htm' + -g '*(/)' w3m lynx mozilla netscape +compctl -g '*.zip' + -g '*(/)' unzip +compctl -g '*.fig' + -g '*(/)' xfig +compctl -g '*.rtf' + -g '*(/)' Ted +compctl -g '*.web' + -g '*(/)' tangle weave ftangle fweave ctangle cweave ctanglex cweavex + +# man: complete commands, otherwise complete by search of $MANPATH. +# This is placed as an all-encompassing pattern at the end because making it +# the default before the -x doesn't work. (It becomes +# '-c + (-K 'match-man' -x ...), not (-c + -K 'match-man') -x ...). +# We also complete paths for -M (override manpath), commands for -P (pager) and +# disable for -S (search sections). After an explicit number (which it helps +# to complete for you), these completion rules assume a thorough search is +# needed and no longer use the '-c' hashed commands, relying entirely on +# what's really in the manpath. +# Also support -l <file> and -T<device> +c_man_var() { + man_pages=( /usr/share/man/man*/*(N:t:r) /usr/man/man*/*(N:t:r) ) + compctl -k man_pages man + reply=( $man_pages ) +} +compctl -x 'S[1][2][3][4][5][6][7][8][9]' -k '(1 2 3 4 5 6 7 8 9)' \ + - 'R[[1-9nlo]|[1-9](|[a-z]),^*]' -K 'match-man' \ + - 's[-M],c[-1,-M]' -g '*(-/)' \ + - 's[-P],c[-1,-P]' -c \ + - 's[-S],s[-1,-S]' -k '( )' \ + - 's[-l],c[-1,-l]' -g '*.[0-9] *.man' \ + - 's[-T]' -k '(X100 X75 ascii latin1 ps X100-12 X75-12 dvi lj4)' \ + - 's[-]' -k '(a d f h k t M P l)' \ + - 'p[1,-1]' -c + -K 'c_man_var' \ + -- man + +function c_enscript_langs { +# languages and file formats for which enscript supports pretty-printing + reply=(`enscript --help-pretty-print | grep '^Name:' | sed -e 's/Name: //'`) +} +compctl -g '*' + -g '*(/)' -x s'[-E][--pretty-print]' -P '=' -K c_enscript_langs \ + - s'[--]' -S '' -k '(columns= pages= file-align= header= no-header\ truncate-lines\ line-numbers\ setpagedevice= escapes\ pretty-print\ pretty-print= font= header-font= fancy-header\ no-job-header\ highlight-bars= indent= filter= borders\ page-prefeed\ no-page-prefeed\ lineprinter\ lines-per-page= mail\ media= copies= newline= missing-characters\ output= printer= quiet\ silent\ landscape\ portrait\ baselineskip= statusdict= title= tabsize= underlay\ nup= verbose\ version\ language= encoding= no-formfeed\ pass-through\ ps-level= rotate-even-pages\ toc\ word-wrap\ )' \ + -- enscript + +############################################################################ +# Networking + +function c_lftp_bookmarks { +# extract the names of bookmarks from the lftp bookmarks file. + reply=(`cut -c '1-17' ~/.lftp/bookmarks \ + | sed -e 's/[^a-zA-Z0-9\-]//g' `); +} +compctl -K c_lftp_bookmarks lftp + +function c_ssh_knownhosts { +# extract the hosts which are known to ssh. + reply=(`sed -e 's/ .*$//' \ + -e 's/,[0-9]\{3\}\..*//' ~/.ssh/known_hosts`); +} +#compctl -K c_ssh_knownhosts ssh + +# Complete the current word with files after a `:', with ssh +# hosts after a `@', and with hosts or files (in that order) +# at the start of a word. +compctl -x 'n[0,:]' -f - 'n[0,@],s[]' -K c_ssh_knownhosts -S: + -f -- \ + scp + +# This completes `ssh [username@]host remotecommand'. +# TODO: how do we get the -X working? +compctl -x \ + 'C[-1,*@*]' -X '<Remote command>' - \ + 'n[0,@],s[]' -K c_ssh_knownhosts \ + -- ssh +#compctl -K c_ssh_knownhosts -x 'c[-1,-l]' -k '()' -X 'Remote user name' -- slogin +#compctl -x 'n[0,@],s[]' -K c_ssh_knownhosts - \ +# 'c[-1,-l]' -k '()' -X 'Remote user name' - \ +# 'C[-1,*@*]' -k '(kiekeboe)' -- ssh + +## As above, but do 'ssh [host] [-l user] [command]' where +## <command> is a separate command line (i.e., to be executed +## via ssh as <user> on <host>). +#compctl -x 'p[1], p[2] C[-1,-*]' -K c_ssh_knownhosts \ +# - 'c[-1,-l]' -K userlist -- \ +# + -x 'w[2,-l] p[4,-1],p[2,-1]' -l '' -- ssh + + +############################################################################ +# Program development + +# strip, profile, and debug only executables. The compctls for the +# debuggers could be better, of course. +compctl -g '*(*)' strip gprof gdb ddd + +# GCC completion, based on Andrew Main's; updated for gcc 2.95.2 . +# completes to filenames (*.c, *.C, *.o, etc.); to miscellaneous options after +# a -; to various -f options after -f (and similarly -W, -g and -m); and to a +# couple of other things at different points. +# The -m completion should be tailored to each system; the one below is i386. +compctl -g '*.([cCmisSoa]|cc|cxx|cpp|ii)' -x \ + 's[-l]' -s '${(s.:.)^LD_LIBRARY_PATH}/lib*.a(:t:r:s/lib//)' - \ + 'c[-1,-x]' -k '(none c objective-c c-header c++ cpp-output assembler ass +embler-with-cpp)' - \ + 'c[-1,-o]' -f - \ + 'C[-1,-i(nclude|macros)]' -g '*.h' - \ + 'C[-1,-i(dirafter|prefix)]' -g '*(-/)' - \ + 's[-B][-I][-L]' -g '*(-/)' - \ + 's[-fno-],s[-f]' -k '(lang-isoc9x + allow-single-precision cond-mismatch asm + builtin freestanding hosted signed-bitfields signed-char + unsigned-bitfields unsigned-char writable-strings + access-control check-new conserve-space dollars-in-identifiers + elide-constructors external-templates for-scope gnu-keywords + guiding-decls handle-signatures honor-std huge-objects + implicit-templates init-priority implement-inlines + name-mangling-version-N default-inline operator-names optional-diags + permissive repo strict-prototype squangle template-depth-N + this-is-variable vtable-chunks + syntax-only + all-virtual dollars-in-identifiers elide-constructors enum-int-equiv + memoize-lookups nonnull-objects + dump-unnumbered pretend-float profile-arcs test-coverage + branch-probabilities optimize-register-moves caller-saves + cse-follow-jumps cse-skip-blocks delayed-branch + expensive-optimizations fast-math float-store force-addr force-mem + data-sections function-sections gcse inline-functions inline-limit-3 + keep-inline-functions default-inline defer-pop function-cse inline + peephole omit-frame-pointer regmove rerun-cse-after-loop + rerun-loop-opt schedule-insns schedule-insns2 strength-reduce + thread-jumps unroll-all-loops unroll-loops move-all-movables + reduce-all-givs strict-aliasing + call-saved- call-used- exceptions fixed- inhibit-size-directive + check-memory-usage prefix-function-name common ident gnu-linker + pcc-struct-return pic PIC reg-struct-return shared-data short-enums + short-double volatile volatile-global volatile-static verbose-asm + pack-struct stack-check argument-alias argument-noalias + argument-noalias-global leading-underscore)' - \ + 's[-g]' -k '(gdb stabs stabs+ coff xcoff xcoff+ dwarf dwarf+ + dwarf-2)' - \ + 's[-mno-][-mno][-m]' -k '(486 ieee-fp no-fancy-math-387 fp-ret-in-387 + soft-float svr3-shlib no-wide-multiply rtd align-double align-jumps= + align-loops= align-functions= preferred-stack-boundary=)' - \ + 's[-Wno-][-W]' -k '( + all aggregate-return bad-function-cast cast-align cast-qual + char-subscripts comment conversion error format id-clash-8 + implicit implicit-int implicit-function-declaration import + error-implicit-function-declaration inline larger-than-64 + long-long main missing-declarations missing-noreturn + missing-prototypes multichar nested-externs import parentheses + pointer-arith redundant-decls return-type shadow sign-compare + strict-prototypes switch traditional trigraphs undef uninitialized + unused write-strings unknown-pragmas + template-debugging + ctor-dtor-privacy deprecated effc++ non-template-friend + non-virtual-dtor old-style-cast overloaded-virtual pmf-conversions + reorder sign-promo synth)' - \ + 's[-]' -k '(pipe ansi traditional traditional-cpp trigraphs pedantic + pedantic-errors nostartfiles nostdlib static shared symbolic include + imacros idirafter iprefix iwithprefix nostdinc nostdinc++ undef + print-file-name= print-libgcc-file-name print-prog-name= + -print-search-dirs -save-temps)' \ + -X 'Use "-f", "-g", "-m" or "-W" for more options' -- gcc g++ + +compctl -x 's[--]' -S '' -k '(verbose\ prefix= exec-prefix= help\ build= host= + norecursion\ program-prefix= program-suffix= program-transform-name= + site= srcdir= target= tmpdir= with- without- enable- disable- )' -- \ + ./configure + +compctl -g '*(/)' \ + -x 's[-]' -P '-' -k '( + sign clearsign detachsign encrypt symmetric store decrypt verify + listkeys listsigs checksigs fingerprint listsecretkeys genkey + deletekey editkey genrevoke export import listpackets + armor localuser remoteuser textmode output verbose batch yes + no keyring secretkeyring defaultkey options debug debugall + statusfd nocomment completesneeded marginalsneeded + loadextension rfc1991 s2kmode s2kdigestalgo s2kcipheralgo + cipheralgo digestalgo compressalgo throwkeyid)' -- gpg + +# procps +# ps +# uptime +compctl -x 'p[1]' -k '(-V)' -- uptime +compctl -x 'p[1]' -k '(-V)' + -k '(-s -d)' -- tload + + +############################################################################ +# Administrative commands + +compctl -u -x 'w[2,-c] p[3,-1]' -l '' - \ + 's[--]' -s 'fast help login preserve-environment shell version' -- su + +#if type rpm >/dev/null; then +#function pkg_glob () { +# if [[ ${REDHAT_PACKAGES:-0} = 0 ]]; then +# export REDHAT_PACKAGES="`rpm -qa`" +# fi +# reply=(${=REDHAT_PACKAGES}) +#} +#function refreshpkgcache () { +# export REDHAT_PACKAGES="`rpm -qa`" +#} +#compctl -f -x \ +# 'c[-1,--root]' -g '*(/)' - \ +# 'W[1,-(-install|i*)] s[--]' -k (hash percent force test replacepkgs replacefiles search root) - \ +# 'W[1,-(-upgrade|u*)] s[--]' -k (hash percent force test search oldpackage root) - \ +# 'C[-1,--(install|upgrade)] s[-],p[1] s[-i],p[1] s[-U]' -X "(h)ash (v)erbose" - \ +# 'W[1,-(-erase|e|-verify|V|y)] s[--]' -k (root) - \ +# 'W[1,-(-erase|e)]' -K pkg_glob - \ +# 'w[1,--query] s[-],p[1] s[-q],p[1] s[-V],p[1] s[-y]' -X \ +#"(a)ll (f)ile+ (F)ile-stdin (p)kg+ (P)kg-Stdin \ +#(i)nfo (l)ist-of-files (s)tates-of-files (d)ocumentation (c)onfiguration" - \ +# 'w[1,--verify] s[-],p[1] s[-V],p[1] s[-y]' -X \ +#"(a)ll (f)ile+ (F)ile-stdin (p)kg+ (P)kg-Stdin" - \ +# 'W[1,-(-verify|-query|q*|V*|y*)] C[-1,*f]' -f - \ +# 'W[1,-(-verify|-query|q*|V*|y*)] C[-1,*p*]' -g '*(D-/) *.rpm(N)' - \ +# 'W[1,-(-verify|-query|q*|V*|y*)]' -K pkg_glob - \ +# 'W[1,--(where|checksig)]' -K pkg_glob - \ +# 'W[1,--rebuild] s[-]' -k (v) - \ +# 'p[1] s[-b]' -X "(p)rep (l)ist (c)ompile (i)install (b)inary (a)ll" - \ +# 'p[2] C[-1,-b*] s[--]' -k (short-circuit clean sign keep-temps test time-check) - \ +# 's[--]' -k (help version install upgrade query verify erase rebuild where checksig) - \ +# 's[-]' -k (- i U q V e b) - \ +# 'c[-1,rpm]' -X "$(rpm)" -- rpm +#fi #if rpm exists + + +compctl -k '(if of conv ibs obs bs cbs files skip file seek count)' \ + -S '=' -x 's[if=], s[of=]' -f - 'C[0,conv=*,*] n[-1,,], s[conv=]' \ + -k '(ascii ebcdic ibm block unblock lcase ucase swap noerror sync)' \ + -q -S ',' - 'n[-1,=]' -X '' -- dd + + +############################################################################ +# Debian specific +source "/usr/share/doc/zsh/examples/compctl.dpkg" + +compctl -x 'c[-1,-x]' -g '*.dsc' + -g '*(/)' - \ + 'c[-1,-b]' -g '*(/)' -- dpkg-source +compctl -g '*.deb' + -g '*(/)' lintian +compctl -g '*.changes' + -g '*(/)' dupload + +#compctl \ +# -x 'p[1]s[--]' \ +# -k '(setup-lab remove-lab check check-part unpack remove \ +# help verbose version debug)' -- \ +# + -x 's[--]' -k '(help verbose version debug)' -- \ +# + -g '*.deb' + -g '*(/)' \ +# lintian + + diff --git a/debian/examples/ssh_completion b/debian/examples/ssh_completion new file mode 100644 index 000000000..53e61d193 --- /dev/null +++ b/debian/examples/ssh_completion @@ -0,0 +1,66 @@ +NOTE: In order for this to work with newer versions of ssh, you must +insure that "HashKnownHosts" is set to "no". + +This will set the variable $hosts to an array containing +all the hosts in ~/.ssh/known_hosts and ~/.ssh/known_hosts2 +that do not start with a digit. + +hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts <$HOME/.ssh/known_hosts2)"}:#[0-9]*}%%\ *}%%,*}) + +This will set the variable $hosts to an array containing +all the hosts in ~/.ssh/known_hosts that do not start with +a digit. + +hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[0-9]*}%%\ *}%%,*}) + +If you are using the new completion system, you can then place + +zstyle ':completion:*:hosts' hosts $hosts + +after compinit is autoloaded to use those anywhere hosts would be +completed, or + +zstyle ':completion:*:complete:ssh:*:hosts' hosts $hosts + +to use those hosts to complete only ssh. + +An explanation of the $hosts assignment, written by Peter Stephenson, +follows. + +$(<$HOME/.ssh/known_hosts) + +is a standard substitution: it simply takes the file and sticks it onto the +command line at that point. + +"$(<$HOME/.ssh/known_hosts)" + +Now it's quoted, it doesn't do word splitting; we have the complete file as +one word. From now on, we do nested substitutions: you just have to +remember that ${${...}}, or ${${...}}, essentially does nothing but an +ordinary parameter expansion --- the whole point is the extra bits tacked +on with each extra set of braces. For example, we're now going to do + +${(f)"$(<$HOME/.ssh/known_hosts)"} + +so we get the same answer, but with the effect of putting the (f) flag at +the start, which splits the result of that into lines. So we now have the +entire file as an array, one line per element. + +${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[0-9]*} +(Clint says the ^ shouldn't be there) says take the array elements (= lines +of the original file) which completely match [0-9]*, i.e. elements +beginning with a digit, and remove them, which is what ${...:#...} is for. + +${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[0-9]*}%%\ *} + +takes the result of that, and strips off from the end the largest pattern +matching ' *', i.e. a space followed by anything else, in other words it +leaves the largest initial string with no whitespace, which is a hostname +(this is a standard ${...%%...} which even ordinary shells do, although not +nested). + +${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[0-9]*}%%\ *}%%,*} + +does another strip at the end, this time for everything from the first +comma on. If there wasn't a comma, nothing changes. You could have +combined the last two as ${...%%[[:blank:],]*}, or something. diff --git a/debian/examples/ssh_completion2 b/debian/examples/ssh_completion2 new file mode 100644 index 000000000..7c6fcb20e --- /dev/null +++ b/debian/examples/ssh_completion2 @@ -0,0 +1,37 @@ +NOTE: In order for this to work with newer versions of ssh, you must +insure that "HashKnownHosts" is set to "no". + +This is what I would call overkill, but it should help illustrate +what some people like to do with ssh completion. +---------- + +zstyle ':completion:*' format 'Completing %d' +zstyle ':completion:*' group-name '' + +zstyle ':completion:*:scp:*' tag-order \ + 'hosts:-host hosts:-domain:domain hosts:-ipaddr:IP\ address *' +zstyle ':completion:*:scp:*' group-order \ + users files all-files hosts-domain hosts-host hosts-ipaddr +zstyle ':completion:*:ssh:*' tag-order \ + users 'hosts:-host hosts:-domain:domain hosts:-ipaddr:IP\ address *' +zstyle ':completion:*:ssh:*' group-order \ + hosts-domain hosts-host users hosts-ipaddr + +zstyle ':completion:*:(ssh|scp):*:hosts-host' ignored-patterns \ + '*.*' loopback localhost +zstyle ':completion:*:(ssh|scp):*:hosts-domain' ignored-patterns \ + '<->.<->.<->.<->' '^*.*' '*@*' +zstyle ':completion:*:(ssh|scp):*:hosts-ipaddr' ignored-patterns \ + '^<->.<->.<->.<->' '127.0.0.<->' +zstyle ':completion:*:(ssh|scp):*:users' ignored-patterns \ + adm bin daemon halt lp named shutdown sync + +zstyle -e ':completion:*:(ssh|scp):*' hosts 'reply=( + ${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) \ + /dev/null)"}%%[# ]*}//,/ } + ${=${(f)"$(cat /etc/hosts(|)(N) <<(ypcat hosts 2>/dev/null))"}%%\#*} + )' + +zstyle ':completion:*:(ssh|scp):*:my-accounts' users-hosts \ + my.secret.account@student.uu.se + |