Bug#792703: zsh: please improve newuser.zshrc.recommended and add new prompt_debian_setup
* Carsten Hey [2015-08-13 12:02 +0200]: I attached a new prompt_debian_setup and an RCS format diff between the former one and this one. Unconditionally using zstyle or other things available in zsh modules only does not make that much sense for the intended purpose ... I already adapted the vcs_info part of the prompt accordingly and will send a new version after I also updated the other parts. Regards Carsten
Bug#792703: zsh: please improve newuser.zshrc.recommended and add new prompt_debian_setup
Hi, I attached a new prompt_debian_setup and an RCS format diff between the former one and this one. The zstyle pattern now is :prompt:debian:${HOST-}:${USERNAME-}:${TERM-}: in order to implement a variant of the suggested terminal blacklist in future. The final : allows additional future extensions, if needed. Additional configurable things would make the prompt more complex, thus I skipped implementing them for now (the suggested ones and additional ones can be implemented later). Franks other suggestions and some minor changes are applied to the new prompt_debian_setup. I think a recommended Debian .zshrc should also work on other systems, at least in future releases of other Linux distributions. Therefore, submitting this prompt_debian_setup upstream would be great, but only a Debian zsh maintainer would be able to say We plan to add this prompt to the Debian zsh package and enable it in the recommended .zshrc for new users. Please consider applying this patch.. According to the channel topic, the zsh 5.0.9 release is expected to happen soonish. Carsten # debian prompt theme prompt_debian_help () { cat 'EOF' This prompt color-scheme-able via zstyle. If the variabale TERM is set to 'dumb', colors are disabled, though. You can invoke the prompt thus: prompt debian TERM=dumb prompt debian To configure the prompt's colors, this command can be used (don't forget to run 'prompt debian' again to activate the changes): zstyle ':prompt:debian:*' STYLE COLOR You need to replace STYLE with 'dircolor', 'usercolor', 'usercolor-root', 'exitcolor' or 'exitcolor-root'. Valid values for COLOR include the numbers from 0 to 7, 'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan' and 'white'. Displaying version control information via vcs_info and displaying the name of a Debian chroot is supported by this prompt, but only the latter is enabled by default. To enable vcs_info with the user-context 'prompt_debian', run: add-zsh-hook precmd prompt_debian_precmd_vcs_info To disable vcs_info even if the vcs_info command is run, and to enable it again, zstyle can be used as shown in the two lines below. The other two lines enable checks for uncommited changes. zstyle ':vcs_info:*' enable NONE zstyle ':vcs_info:*' enable ALL zstyle ':vcs_info:*' check-for-staged-changes true zstyle ':vcs_info:*' check-for-changes true To add additional information to the prompt, e.g., the history event number or the number of background jobs and the shell level, this commands can be used. The content of the 'nvcsformats' style is only shown if vcs_info is used, but no version control system repository was found. PROMPT='%B!%!%b '$PROMPT zstyle ':vcs_info:*' nvcsformats '%B%F{green}%(1j.j%j .)%(2L.L%L .)%b%f' EOF } prompt_debian_precmd_vcs_info () { setopt localoptions no_xtrace vcs_info prompt_debian || return $? } prompt_debian_setup () { setopt localoptions no_errexit no_errreturn prompt_opts=(cr subst percent) local zstyle_pattern=:prompt:debian:${HOST-}:${USERNAME-}:${TERM-}: local dir_max_length='60' local dir_max_elements='5' local wrap_at_char='-25' local p_exit='${${options[printexitvalue]#on}:+%0(?..%? )}' local p_dir=%${dir_max_length}...%$(( dir_max_elements + 1 ))(~:.../:)%${dir_max_elements}~% local p_space_or_newline=%${wrap_at_char}(l: :${prompt_newline}) local p_vcsinfo='${vcs_info_msg_0_-}' local p_reset='%b%f%k' local p_2nd_newline=%1(l:%${wrap_at_char}(l..${prompt_newline}):) if [[ ${TERM-} == dumb ]]; then PROMPT=$p_exit\${debian_chroot:+(\$debian_chroot)}%n@%m $p_dir PROMPT+=$p_space_or_newline$p_vcsinfo$p_reset$p_2nd_newline%# else # color config: local exitcolor exitcolor_root usercolor usercolor_root dircolor zstyle -s $zstyle_pattern exitcolor exitcolor || exitcolor='red' zstyle -s $zstyle_pattern exitcolor-root exitcolor_root || exitcolor_root='green' zstyle -s $zstyle_pattern usercolor usercolor || usercolor='green' zstyle -s $zstyle_pattern usercolor-root usercolor_root || usercolor_root='red' zstyle -s $zstyle_pattern dircolor dircolor || dircolor='blue' PROMPT=%B%{%0(#:%F{$exitcolor_root}:%F{$exitcolor})%}$p_exit PROMPT+=%{%F{$dircolor}%}\${debian_chroot:+(} PROMPT+=%{%0(#:%F{$usercolor_root}:%F{$usercolor})%}\${debian_chroot-} PROMPT+=%{%F{$dircolor}%}\${debian_chroot:+)} PROMPT+=%{%0(#:%F{$usercolor_root}:%F{$usercolor})%}%n@%m PROMPT+=%{%F{$dircolor}%}$p_dir%b%f PROMPT+=$p_space_or_newline$p_vcsinfo$p_reset$p_2nd_newline%B%#%b fi # Only try
Bug#792703: zsh: please improve newuser.zshrc.recommended and add new prompt_debian_setup
A new prompt_debian_setup that no longer tries to mimic adam1 is attached. I think #setopt no_beep and #stty -ixon should also be added to newuser.zshrc.recommended, but maybe we should concentrate on the prompt for now. # debian prompt theme prompt_debian_help () { cat 'EOF' This prompt color-scheme-able via zstyle. If the variabale TERM is set to 'dumb', colors are disabled, though. You can invoke the prompt thus: prompt debian TERM=dumb prompt debian To configure the prompt's colors, this command can be used (don't forget to run 'prompt debian' again to activate the changes): zstyle ':prompt:debian:*' STYLE COLOR You need to replace STYLE with 'dircolor', 'usercolor', 'usercolor-root', 'exitcolor' or 'exitcolor-root'. Valid values for COLOR include the numbers from 0 to 7, 'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan' and 'white'. Displaying version control information via vcs_info and displaying the name of a Debian chroot is supported by this prompt, but only the latter is enabled by default. To enable vcs_info with the user-context 'prompt_debian', run: add-zsh-hook precmd prompt_debian_precmd_vcsinfo To disable vcs_info even if the vcs_info command is run, and to enable it again, zstyle can be used as shown in the two lines below. The other two lines enable checks for uncommited changes. zstyle ':vcs_info:*' enable NONE zstyle ':vcs_info:*' enable ALL zstyle ':vcs_info:*' check-for-staged-changes true zstyle ':vcs_info:*' check-for-changes true To add additional information to the prompt, e.g., the history event number or the number of background jobs and the shell level, this commands can be used. The content of the 'nvcsformats' style is only shown if vcs_info is used, but no version control system repository was found. PROMPT='%B!%!%b '$PROMPT zstyle ':vcs_info:*' nvcsformats '%B%F{2}%(1j.j%j .)%(2L.L%L .)%b%f' EOF } prompt_debian_precmd_vcsinfo () { setopt localoptions noxtrace vcs_info prompt_debian || return $? } prompt_debian_setup () { prompt_opts=(cr subst percent) local zstyle_pattern=:prompt:debian:${HOST:-unknown}:${USERNAME:-unknown} local pwd_max_length=60 local pwd_max_subdirs=5 local wrap_at_char='-25' local p_exit='${${options[printexitvalue]#on}:+%0(?..%? )}' local p_pwd=%${pwd_max_length}...%$(( pwd_max_subdirs + 1 ))(~:.../:)%${pwd_max_subdirs}~% local p_space_or_newline=%${wrap_at_char}(l: :${prompt_newline}) local p_vcsinfo='${vcs_info_msg_0_-}' local p_reset='%b%f%k' local p_2nd_newline=%1(l:%${wrap_at_char}(l..${prompt_newline}):) if [[ ${TERM-} == dumb ]]; then PROMPT=$p_exit\${debian_chroot:+(\$debian_chroot)}%n@%m $p_pwd PROMPT+=$p_space_or_newline$p_vcsinfo$p_reset$p_2nd_newline%# else # color config: local dircolor= usercolor= usercolor_root= exitcolor= exitcolor_root= zstyle -s $zstyle_pattern dircolor dircolor zstyle -s $zstyle_pattern usercolor usercolor zstyle -s $zstyle_pattern usercolor-root usercolor_root zstyle -s $zstyle_pattern exitcolor exitcolor zstyle -s $zstyle_pattern exitcolor-root exitcolor_root : ${dircolor:=4} ${usercolor:=2} ${usercolor_root:=1} : ${exitcolor:=1} ${exitcolor_root:=2} PROMPT=%B%{%0(#:%F{$exitcolor_root}:%F{$exitcolor})%}$p_exit PROMPT+=%{%F{$dircolor}%}\${debian_chroot:+(} PROMPT+=%{%0(#:%F{$usercolor_root}:%F{$usercolor})%}\${debian_chroot-} PROMPT+=%{%F{$dircolor}%}\${debian_chroot:+)} PROMPT+=%{%0(#:%F{$usercolor_root}:%F{$usercolor})%}%n@%m PROMPT+=%{%F{$dircolor}%}$p_pwd%b%f PROMPT+=$p_space_or_newline$p_vcsinfo$p_reset$p_2nd_newline%B%#%b ##TODO uncomment if setopt transientrprompt works in a prompt function ## Ease copying multi-line commands with the mouse. ## http://www.zsh.org/mla/workers/2015/msg01767.html #local rps2color=$dircolor #setopt transient_rprompt #PS2='${${options[singlelinezle]#off}:+%_ }' #RPS2=${RPS2:-%B%{%F{$rps2color}%}%^%f%b} fi # Only try to set $debian_chroot if it is unset. if [[ ! ${debian_chroot+set} -r /etc/debian_chroot ]] then debian_chroot=$( /etc/debian_chroot || :) fi # Autoload and configure vcs_info: # The format strings 'formats' and 'actionformats' should end with a space # to fit into the prompt's design. # Colors: 1:=red, 2:=green, 3:=yellow, 4:=blue, 5:=magenta, 6:=cyan, ... autoload -Uz vcs_info if [[ ${TERM-} == dumb ]]; then zstyle ':vcs_info:*:prompt_debian:*' formats '[%s|%b%c%u] ' zstyle ':vcs_info:*:prompt_debian:*' actionformats '[%s-%a|%b%c%u] ' zstyle ':vcs_info:(sv[nk]|bzr):prompt_debian:*' branchformat '%b:%r' zstyle ':vcs_info:*:prompt_debian:*' stagedstr '(S)' zstyle ':vcs_info:*:prompt_debian:*'
Bug#756138: Bug#792703: zsh: please improve newuser.zshrc.recommended and add new prompt_debian_setup
Hi Carsten, I looked through the suggestions from your last mail; comments inline. Carsten Hey wrote: [...] I think #setopt no_beep and #stty -ixon should also be added to The latter might better be replaced by zsh's no_flow_control option. [...] This prompt color-scheme-able via zstyle. If the variabale TERM is set to 'dumb', colors are disabled, though. You can invoke the prompt thus: prompt debian TERM=dumb prompt debian You could also check something like a blacklist style, that could be a list of term names (or better yet, patterns). That way you could blacklist $TERMs like emacs for colours as well. To configure the prompt's colors, this command can be used (don't forget to run 'prompt debian' again to activate the changes): zstyle ':prompt:debian:*' STYLE COLOR Good! I like it when people refrain from polluting the global parameter name space just for prompt colours. This is good. :-) [...] Displaying version control information via vcs_info and displaying the name of a Debian chroot is supported by this prompt, but only the latter is enabled by default. To enable vcs_info with the user-context 'prompt_debian', run: add-zsh-hook precmd prompt_debian_precmd_vcsinfo Makes sense. [...] PROMPT='%B!%!%b '$PROMPT zstyle ':vcs_info:*' nvcsformats '%B%F{2}%(1j.j%j .)%(2L.L%L .)%b%f' Maybe use a name rather than a number here: %F{green} EOF } prompt_debian_precmd_vcsinfo () { setopt localoptions noxtrace vcs_info prompt_debian || return $? } prompt_debian_setup () { prompt_opts=(cr subst percent) local zstyle_pattern=:prompt:debian:${HOST:-unknown}:${USERNAME:-unknown} local pwd_max_length=60 local pwd_max_subdirs=5 local wrap_at_char='-25' Maybe make these configurable via styles? local p_exit='${${options[printexitvalue]#on}:+%0(?..%? )}' local p_pwd=%${pwd_max_length}...%$(( pwd_max_subdirs + 1 ))(~:.../:)%${pwd_max_subdirs}~% local p_space_or_newline=%${wrap_at_char}(l: :${prompt_newline}) local p_vcsinfo='${vcs_info_msg_0_-}' local p_reset='%b%f%k' local p_2nd_newline=%1(l:%${wrap_at_char}(l..${prompt_newline}):) I think that looks reasonable. if [[ ${TERM-} == dumb ]]; then PROMPT=$p_exit\${debian_chroot:+(\$debian_chroot)}%n@%m $p_pwd PROMPT+=$p_space_or_newline$p_vcsinfo$p_reset$p_2nd_newline%# else # color config: local dircolor= usercolor= usercolor_root= exitcolor= exitcolor_root= zstyle -s $zstyle_pattern dircolor dircolor zstyle -s $zstyle_pattern usercolor usercolor zstyle -s $zstyle_pattern usercolor-root usercolor_root zstyle -s $zstyle_pattern exitcolor exitcolor zstyle -s $zstyle_pattern exitcolor-root exitcolor_root : ${dircolor:=4} ${usercolor:=2} ${usercolor_root:=1} : ${exitcolor:=1} ${exitcolor_root:=2} To set defaults you can do: zstyle -s $zstyle_pattern dircolor dircolor || dircolor=4 And again, maybe rather use names instead of numbers: zstyle -s $zstyle_pattern dircolor dircolor || dircolor=blue You also don't need to initialise to the empty string in the local above. PROMPT=%B%{%0(#:%F{$exitcolor_root}:%F{$exitcolor})%}$p_exit PROMPT+=%{%F{$dircolor}%}\${debian_chroot:+(} PROMPT+=%{%0(#:%F{$usercolor_root}:%F{$usercolor})%}\${debian_chroot-} PROMPT+=%{%F{$dircolor}%}\${debian_chroot:+)} PROMPT+=%{%0(#:%F{$usercolor_root}:%F{$usercolor})%}%n@%m PROMPT+=%{%F{$dircolor}%}$p_pwd%b%f PROMPT+=$p_space_or_newline$p_vcsinfo$p_reset$p_2nd_newline%B%#%b Assembling a non-trivial prompt like always looks unreadable. I've seen worse than this. ##TODO uncomment if setopt transientrprompt works in a prompt function ## Ease copying multi-line commands with the mouse. ## http://www.zsh.org/mla/workers/2015/msg01767.html #local rps2color=$dircolor #setopt transient_rprompt I don't understand this. transientrprompt can — and IMO should be — set outside a prompt setup. #PS2='${${options[singlelinezle]#off}:+%_ }' I'd do this in an if ...; then...; fi to improve readability. #RPS2=${RPS2:-%B%{%F{$rps2color}%}%^%f%b} [...] # Autoload and configure vcs_info: # The format strings 'formats' and 'actionformats' should end with a space # to fit into the prompt's design. # Colors: 1:=red, 2:=green, 3:=yellow, 4:=blue, 5:=magenta, 6:=cyan, ... Again, you can use the colour names instead of the numbers instead. [...] The contents of the .thisfiledoesnotexist file seems very similar to the one of the prompt_debian_setup file. Attached by mistake? Regards, Frank -- In protocol design, perfection has been reached not when there is nothing left to add, but when there is nothing left to take away. -- RFC
Bug#792703: zsh: please improve newuser.zshrc.recommended and add new prompt_debian_setup
[ dropping #756138 again from CC, people reading it should now know that there is a related bug ] Hi Frank, thanks a lot for you insightful feedback :) I noticed, that I should add a note how to disable displaying the name of a debian chroot (i.e., set it to or unset it). * Frank Terbeck [2015-08-08 17:28 +0200]: Carsten Hey wrote: [...] I think #setopt no_beep and #stty -ixon should also be added to The latter might better be replaced by zsh's no_flow_control option. Indeed, setopt no_flow_control is much better. [...] This prompt color-scheme-able via zstyle. If the variabale TERM is set to 'dumb', colors are disabled, though. You can invoke the prompt thus: prompt debian TERM=dumb prompt debian You could also check something like a blacklist style, that could be a list of term names (or better yet, patterns). That way you could blacklist $TERMs like emacs for colours as well. Looks like emacs used to set TERM to dumb (see #143361), but this might have changed. Anyway, the blacklist is a great idea, the default blacklist would currently contain emacs and dumb. zstyle ':prompt:debian:*' STYLE COLOR Hmm, even if * matches :, this could be changed to ':prompt:debian:*:*' (one * for the host name and one for the user name). PROMPT='%B!%!%b '$PROMPT zstyle ':vcs_info:*' nvcsformats '%B%F{2}%(1j.j%j .)%(2L.L%L .)%b%f' Maybe use a name rather than a number here: %F{green} At least for the examples shown in the help text %F{green} is much more readable. local pwd_max_length=60 local pwd_max_subdirs=5 local wrap_at_char='-25' Maybe make these configurable via styles? It was configurable, but I assumed that nobody would care about being able to configure this and removed it again - looks like I was wrong. The additional file I attached contains a part of what is required to make it configurable via styles, just in case I'll need it in the future. I'll also add local enable_exit_status=1 again in order to make this configurable too. # color config: local dircolor= usercolor= usercolor_root= exitcolor= exitcolor_root= zstyle -s $zstyle_pattern dircolor dircolor zstyle -s $zstyle_pattern usercolor usercolor zstyle -s $zstyle_pattern usercolor-root usercolor_root zstyle -s $zstyle_pattern exitcolor exitcolor zstyle -s $zstyle_pattern exitcolor-root exitcolor_root : ${dircolor:=4} ${usercolor:=2} ${usercolor_root:=1} : ${exitcolor:=1} ${exitcolor_root:=2} To set defaults you can do: zstyle -s $zstyle_pattern dircolor dircolor || dircolor=4 And again, maybe rather use names instead of numbers: zstyle -s $zstyle_pattern dircolor dircolor || dircolor=blue You also don't need to initialise to the empty string in the local above. zstyle -s ... || dircolor=... looks a lot cleaner than what I had. I'm undecided, but easily convincible, whether color names or numbers should be used in a string that users won't see (unless they do print -r -- $PROMPT and try to understand the output), given that the numbers are shorter. ##TODO uncomment if setopt transientrprompt works in a prompt function ## Ease copying multi-line commands with the mouse. ## http://www.zsh.org/mla/workers/2015/msg01767.html #local rps2color=$dircolor #setopt transient_rprompt I don't understand this. transientrprompt can — and IMO should be — set outside a prompt setup. Without transient_rprompt, the painless multiline copying won't work and therefore there would be no reason to set PS2 and RPS2 accordingly. I assume one has to read the linked thread to fully understand what the purpose of this four lines is (or try it interactively). Alternative approaches are: * setting PS2 and RPS2 and expecting the user to set transient_rprompt (which is fine for a default .zshrc, but might not be the best idea if used in a hand-written .zshrc) * providing a function users are able to call if they want this behaviour - this sounds like a good approach if it is done independent from a specific prompt #PS2='${${options[singlelinezle]#off}:+%_ }' I'd do this in an if ...; then...; fi to improve readability. An if condition would not catch cases when singlelinezle is set after the prompt's setup function is run (we don't build the prompt in a precmd) - OTOH this is not an option many people would set. The contents of the .thisfiledoesnotexist file seems very similar to the one of the prompt_debian_setup file. Attached by mistake? It contains some additional lines (as mentioned above) I expected to need in some years, if at all - but apparently I need them in this year. Carsten -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#792703: zsh: please improve newuser.zshrc.recommended and add new prompt_debian_setup
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? # 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 $@ # 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'
Bug#792703: zsh: please improve newuser.zshrc.recommended and add new prompt_debian_setup
Package: zsh Severity: wishlist Hi, there is an additional, related, bug report in this one. The actual bug report starts below the three dashes. If I use the color-enabling zstyle ':vcs_info:*' formats string from zshcontrib(1), it does not only add colors, but also slightly modifies the format. In the example below, a space is removed and a minus is replaced with a space. I would expect that such an documented example format only modifies the colors - but YMMV. ~% setopt prompt_percent prompt_subst ~% autoload -Uz add-zsh-hook vcs_info ~% add-zsh-hook precmd vcs_info ~% PROMPT='%~$vcs_info_msg_0_%# ' ~% cd gittest ~/gittest (git)-[master]-% zstyle ':vcs_info:*' formats '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{5}]%f ' ~/gittest(git)-[master] % The above format string without the trailing space is used (if uncommented) in the improved newuser.zshrc.recommended and I think at least in this file should a format string be used that only adds colors and changes nothing else. OTOH, I think the default trailing minus does not make that much sense, but I also assume that it won't be removed. Anyway this detail of the improved newuser.zshrc.recommended can still be changed in future. The same possible documentation issue might, or might not, apply to the example actionformats and branchformat strings. It would be great if there would be a way to get a colorful vcs_info without copying around (or alternatively, understanding) format strings; for example running vcs_info --setup-only --enable-colors could set up colorful format strings, but not execute vcs_info's vcs foo. Such options could be used in the improved newuser.zshrc.recommended. The obvious generalisation of --enable-colors is adding support for themes that can be enabled via command line option. --- Clint did a great job with his newuser.zshrc.recommended, he even added proper integration into zsh upstream and added instructions for inexperienced users (Hit TAB ...). Anyway, there are still some small issues that could be fixed and things that could be improved (I might have missed to list some things I changed): * On white terminals, the recommended prompt for new users looks like the broken hourly cron syslog entry - both contain three characters equivalent to spaces in a row. The obvious fix for the prompt is not using white text on white background. * On white terminals, default foreground color on blue background is suboptimal too, white on blue is way better. * There is no (non-insane) way to add vcs_info to the used adam1 prompt. * debian_chroot support is missing and can't easily be added to the used prompt either. * An exit code != 0 is not displayed, but IMHO this is useful. There are two common ways how this is done, either added to the prompt in some way, or using printexitvalue (known from tcsh) - I prefer the latter. * Menu select is only enabled if there are a lot of matches, I first assumed that this might be a bug, but it looks like this was done by intension. I agree that it is more useful if there are a lot of matches, but it is still useful otherwise; and either always enabling or always disabling this feature makes zsh feel more consistent. * A completion with _correct and _approximate might be useful for some users and confuse others - presumably especially long time unix/linux users, but also some new users don't expect their shell to behave like a desktop word processor. I think such a feature should be out-in. * Some default aliases could be useful, at least ll seems to be used all around. I also added h=history. l and la could be added too. * The .zshrc could use a layout that is more consistent to itself and zshall(1): + One comment line ends with a colon (I think I wrote this line), the others don't. + History related options and history related variables should be part of the same part of the file, but are split by bindkeys -e. + One comment is followed by an empty line, others don't. + zshall(1) writes option names with _ between the words, which improves readability, and, if used the same way in a .zshrc, eases searching for the option in the man page. The two files can be found at: http://stateful.de/~carsten/tmp/150717QVwIxjFQx9U/prompt_debian_setup http://stateful.de/~carsten/tmp/150717QVwIxjFQx9U/newuser.zshrc.recommended prompt_debian_setup should be submitted for inclusion in zsh after being added to Debian's zsh. The design and the source code of prompt_debian_setup was originally based on prompt_adam1_setup and there might still be some lines from it. Anything copyrightable (if there is something copyrightable in it at all) in it that is not copied from prompt_adam1_setup is published under the most liberal, public domain equivalent, license possible. On request, I'll assign copyright to zsh's upstream. The
Bug#792703: zsh: please improve newuser.zshrc.recommended and add new prompt_debian_setup
* Carsten Hey [2015-07-17 18:22 +0200]: http://stateful.de/~carsten/tmp/150717QVwIxjFQx9U/prompt_debian_setup http://stateful.de/~carsten/tmp/150717QVwIxjFQx9U/newuser.zshrc.recommended c894f695cc02f16af429c7506bb78354dcd9a1e3 looks like the final PROMPT+= line in prompt_debian_setup could be replaced with this shorter one: PROMPT+='%(!:#:\$)%b%f%k ' -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org