1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-01-01 05:16:05 +01:00

22013: initial go at a working zsh-newuser-install

This commit is contained in:
Peter Stephenson 2005-11-23 11:29:20 +00:00
parent e14491ea7f
commit 325a7c0417
5 changed files with 1098 additions and 37 deletions

View file

@ -1,3 +1,9 @@
2005-11-23 Peter Stephenson <pws@csr.com>
* 22013: INSTALL, NEWS, Completion/compinstall,
Functions/Newuser/zsh-newuser-install: initial go at a
working zsh-newuser-install function.
2005-11-22 Clint Adams <clint@zsh.org>
* 22012: Completion/Debian/Command/_mergechanges:

View file

@ -1,3 +1,5 @@
# Configure the completion system.
emulate -L zsh
setopt extendedglob
@ -25,11 +27,25 @@ __ci_newline() {
typeset startline='# The following lines were added by compinstall'
typeset endline='# End of lines added by compinstall'
typeset ifile line fpath_line compinit_args
typeset ifile line fpath_line compinit_args opt detect basic line2
typeset -A styles
typeset match mbegin mend warn_unknown warn_old warn_comment
typeset match mbegin mend warn_unknown warn_old warn_comment output
integer lines_found
while getopts "do" opt; do
case $opt in
(d)
# Detect an existing compinstall setup.
detect=1
;;
(o)
# Output basic setup information only.
basic=1
;;
esac
done
#
# Check the user's .zshrc, if any.
#
@ -60,6 +76,40 @@ else
fi
fi
if [[ -n $detect ]]; then
__ci_tidyup
[[ $foundold = true ]]
return
fi
__ci_output() {
print -r "$startline"
[[ -n $output ]] && print -r "$output"
if [[ -n $ifile ]]; then
line="zstyle :compinstall filename ${(qq)ifile}"
print -r "$line"
eval "$line"
fi
[[ -n $fpath_line ]] && print -r "$fpath_line"
print -r "
autoload -Uz compinit
compinit${compinit_args:+ $compinit_args}"
print -r "$endline"
}
if [[ -n $basic ]]; then
__ci_output
__ci_tidyup
return
fi
local newifile=$ifile
if [[ $foundold = true ]]; then
print "I have found completion definitions in $ifile.
@ -92,8 +142,19 @@ ifile=$newifile
if [[ $foundold = true ]]; then
sed -n "/^[ ]*$startline/,/^[ ]*$endline/p" $ifile |
# Use the default read behaviour to handle any continuation lines.
while read line; do
# We can't use the default read behaviour to handle continuation lines
# since it messes up internal backslashes.
while read -r line; do
# detect real continuation backslashes by checking there are an
# odd number together. i think this is reliable since the only
# other way of quoting a backslash involves following it with
# a closing quote.
while [[ $line = *\\ ]]; do
line2=${(M)line%%\\##}
(( ${#line2} & 1 )) || break
read -r line2 || break
line="${line[1,-2]}$line2"
done
(( lines_found++ ))
if [[ $line = *'$fpath'* ]]; then
fpath_line=$line
@ -119,7 +180,7 @@ ${match[3]}"
then
compinit_args=$match[1]
elif [[ $line != [[:blank:]]# &&
$line != [[:blank:]]#'autoload -Uz compinit' &&
$line != [[:blank:]]#'autoload '*' compinit' &&
$line != [[:blank:]]#compinit &&
$line != [[:blank:]]#zstyle[[:blank:]]#:compinstall* ]]; then
warn_unknown="${warn_unknown:+$warn_unknown
@ -379,7 +440,7 @@ o. Set options for _oldlist: when to keep old list.
m. Set options for _match: whether to assume a \`*' at the cursor.
p. Set options for _prefix: whether to add a space before the suffix.
q. Return to the without saving.
q. Return to the previous menu without saving.
0. Done setting completer options.
"
@ -1848,15 +1909,13 @@ q. Return without saving.
done
local output
if (( $#styles )); then
typeset style stylevals context values
for style in ${(ko)styles}; do
stylevals=(${(f)styles[$style]})
while (( $#stylevals )); do
output="$output
zstyle ${(qq)stylevals[1]} $style $stylevals[2]"
zstyle ${(qq)stylevals[1]} $style ${stylevals[2]}"
shift 2 stylevals
done
done
@ -1875,22 +1934,7 @@ local tmpout=${TMPPREFIX:-/tmp/zsh}compinstall$$
# Assemble the complete set of lines to
# insert.
#
{ print -r "$startline
$output"
if [[ -n $ifile ]]; then
line="zstyle :compinstall filename ${(qq)ifile}"
print -r "$line"
eval "$line"
fi
[[ -n $fpath_line ]] && print -r "$fpath_line"
print -r "
autoload -Uz compinit
compinit${compinit_args:+ $compinit_args}"
print -r "$endline"
} >$tmpout
__ci_output >$tmpout
if [[ -n $ifile ]]; then
if [[ $ifile != *(zshrc|zlogin|zshenv) ]]; then

File diff suppressed because it is too large Load diff

25
INSTALL
View file

@ -231,6 +231,31 @@ Note that this is mutually exclusive with using the source directories
as make can become confused by build files created in the source directories.
================================
AUTOMATIC NEW USER CONFIGURATION
================================
In the default configuration, the shell comes with a system based around
the zsh/newuser add-on module that detects when a user first starts the
shell interactively and has no initialisation files (.zshenv, .zshrc,
.zprofile or .zlogin). The shell then executes code in the file
scripts/newuser in the shared library area (by default
/usr/local/share/zsh/<VERSION>/scripts/newuser). This feature can be
turned off simply by removing this script. The module can be removed
entirely from the configured shell by editing the line starting
"name=zsh/newuser" int the config.modules file, which is generated in the
top level distribution directory during configuration: change the line to
include "link=no auto=no".
The supplied script executes the function supplied as
Functions/Newuser/zsh-newuser-install. This function is currently under
development. It is probably preferable for administrators who wish to
customize the system their own way to edit the newuser script in
scripts/newuser. Also, as there is currently no internationalization
support, administrators of sites with users who mostly do not speak English
may wish not to install the zsh/newuser module.
=====================
CONFIGURATION OPTIONS
=====================

4
NEWS
View file

@ -8,6 +8,10 @@ Major changes between versions 4.2 and 4.3
- There is support for multibyte character sets in the line editor,
though not the main shell. See Multibyte Character Support in INSTALL.
- The shell can now run an installation function for a new user
(one with no .zshrc, .zshenv, .zprofile or .zlogin file) without
any additional setting up by the administrator.
- New option PROMPT_SP, on by default, to work around the problem that the
line editor can overwrite output with no newline at the end.