[Pkg-zsh-devel] Bug#792703: zsh: please improve newuser.zshrc.recommended and add new prompt_debian_setup

Carsten Hey carsten at debian.org
Sat Jul 25 01:03:50 UTC 2015


If you add the attached files you do not read the other two mails :)


The attached prompt_debian_setup is updated all around:

  * The prompt is not color-scheme-able anymore (the way all prompts do
    it is ugly, and introducing a new way to do this is beyond the scope
    of this bug report) - this also makes the funtion quite small.
  * It now looks like adam1 on black terminals, but much better on light
    terminals.
  * $vcs_info_msg_1_ should not be part of $PROMPT, therefore I removed
    it.
  * Setting debian_chroot to '' disables displaying it.
  * The help function is improved.


The h=history alias is removed from the attached newuser.zshrc.recommended.

Possible things to discuss after this file has been added to the package:

  * dircolors:
    - Use colored ls by default, i.e., use an according ls alias; or
      at least make it easier to enable by adding "#alias ls='ls
      --color=auto"?
    - Should dircolors really be run w/o checking if it is available?
    - Use ~/.dircolors if available?
  * Add some additional aliases?
  * Set the exit code of the most recent executed command to 0, i.e.,
    run : at the end of the file (we use print_exit_value ...)?
  * Use /etc/zsh_command_not_found is available, but only after this
    package is updated?
-------------- next part --------------
# debian prompt theme

prompt_debian_help () {
  cat <<'EOF'
This prompt is currently not color-scheme-able.  You can invoke it thus:

  prompt debian

Displaying version control information via vcs_info and displaying
the name of a Debian chroot is supported by this prompt.

Displaying version control information is disabled by default.
To enable it, invoke the function vcs_info in a precmd function.
If the variable $vcs_info_msg_0_, which is set by vcs_info, is not
empty, its content is shown in the prompt. Other vcs_info variables,
i.e., $vcs_info_msg_N_, are ignored by this prompt, but they can be
used in an user supplied $RPROMPT or in a precmd function.

Displaying the name of the Debian chroot, if any, is enabled by default.
To disable it, unset $debian_chroot after enabling the debian prompt.
An other way to disable it is to set $debian_chroot to an empty string.

The options prompt_cr, prompt_subst and prompt_percent are set.
It is suggested to also set the option print_exit_value.
EOF
}

prompt_debian_setup () {

  prompt_opts=(cr subst percent)

  if [[ -z ${debian_chroot+set} && -r /etc/debian_chroot ]]
  then debian_chroot=$(</etc/debian_chroot) || :
  fi

  PROMPT='%F{white}%K{blue}${debian_chroot:+($debian_chroot)}%n@%m%f%k '
  PROMPT+='%B%F{cyan}%(5/:.../:)%4~%b%f '
  PROMPT+='${vcs_info_msg_0_:+${vcs_info_msg_0_# }%b%f%k }'
  PROMPT+='%B%#%b%f%k '
}

prompt_debian_setup "$@"
-------------- next part --------------
# Set up the prompt:
autoload -Uz add-zsh-hook promptinit vcs_info
promptinit

(( ${+prompt_themes[(r)debian]} )) && prompt debian || prompt adam1
setopt print_exit_value

# Uncomment the next line to enable vcs_info; the second line adds colors:
#add-zsh-hook precmd vcs_info
#zstyle ':vcs_info:*' formats '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{5}]%f'


# Use emacs keybindings even if our EDITOR is set to vi:
bindkey -e


# Alias definitions:
alias ll='ls -l'


# Keep 1000 lines of history within the shell and save it to ~/.zsh_history:
HISTSIZE=1000
SAVEHIST=1000
HISTFILE=~/.zsh_history

setopt hist_ignore_all_dups share_history


# Use modern completion system:
autoload -Uz compinit
compinit

zstyle ':completion:*' auto-description 'specify: %d'
zstyle ':completion:*' completer _expand _complete # _correct _approximate
zstyle ':completion:*' format 'Completing %d'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' menu select=2
eval "$(dircolors -b)"
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*'
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
zstyle ':completion:*' use-compctl false
zstyle ':completion:*' verbose true

zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'


More information about the Pkg-zsh-devel mailing list