Skip to content

Commit

Permalink
Update help directory selection.
Browse files Browse the repository at this point in the history
I haven't managed to test this, as brew doesn't give an easy way to
install the zsh help files.
  • Loading branch information
mattfoster committed Jan 17, 2011
1 parent 0556eba commit a752ba2
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 52 deletions.
29 changes: 25 additions & 4 deletions 01_path
Expand Up @@ -5,6 +5,8 @@
# won't be added to the path unless they do.
#

local pathdirs mandirs funcdirs helpdirs

# Create a list of directories to add to the path
pathdirs=(
/Library/Frameworks/Python.framework/Versions/Current/bin
Expand Down Expand Up @@ -32,7 +34,7 @@ for dir ($pathdirs) {
}

# Allow MacPorts man pages and others
dirs=(
mandirs=(
/usr/local/git/man
/sw/share/man
/opt/local/man
Expand All @@ -41,7 +43,7 @@ dirs=(
)

# Add directories which exist to the manpath
for dir ($dirs) {
for dir ($mandirs) {
if [[ -x $dir ]]; then
manpath=($manpath $dir)
fi
Expand All @@ -54,14 +56,33 @@ local install_path=$binary:h:h # Strip bin/zsh to find installation path.
funcdirs=(
$HOME/.zsh/func
$install_path/share/zsh/$ZSH_VERSION/functions
$install_path/share/zsh/functions
/usr/share/zsh/$ZSH_VERSION/functions
/usr/share/zsh/functions
)

# Add exxisting function directories to the fpath
# Add existing function directories to the fpath
for dir ($funcdirs) {
if [[ -x $dir ]]; then
fpath=($fpath $dir)
fi
}

typeset -gU path cdpath manpath fpath
# Directories for run-help: see 03_help.
helpdirs=(
$HOME/.zsh/help
$install_path/share/zsh/$ZSH_VERSION/zsh_help
$install_path/share/zsh/zsh_help
/usr/share/zsh/$ZSH_VERSION/zsh_help
/usr/share/zsh/zsh_help
)

for dir ($helpdirs) {
if [[ -x $dir ]]; then
helpdir=($fpath $dir)
fi
}

typeset -gU path cdpath manpath fpath helpdir

# vim: set syn=zsh:
100 changes: 52 additions & 48 deletions 03_help
Expand Up @@ -2,58 +2,62 @@
if [[ $(whence -v run-help) == 'run-help is a shell function' ]]; then
unalias run-help
fi
export HELPDIR='/sw/share/zsh/zsh_help'
autoload -Uz run-help
# From zsh-helpfiles (see fink)
alias help=run-help

# From zsh-lovers
# Function Usage: doc packagename
if [[ -d /sw/share/doc ]]; then
doc() { cd /sw/share/doc/$1 && ls }
gdoc() { cd /sw/share/doc/$1 && gvim . }
_doc() { _files -W /sw/share/doc -/ }
elif [[ -d /usr/share/doc ]]; then
doc() { cd /usr/share/doc/$1 && ls }
gdoc() { cd /usr/share/doc/$1 && gvim . }
_doc() { _files -W /usr/share/doc -/ }
fi

# provide useful information on globbing
H-Glob() {
echo -e "
/ directories
. plain files
@ symbolic links
= sockets
p named pipes (FIFOs)
* executable plain files (0100)
% device files (character or block special)
%b block special files
%c character special files
r owner-readable files (0400)
w owner-writable files (0200)
x owner-executable files (0100)
A group-readable files (0040)
I group-writable files (0020)
E group-executable files (0010)
R world-readable files (0004)
W world-writable files (0002)
X world-executable files (0001)
s setuid files (04000)
S setgid files (02000)
t files with the sticky bit (01000)
print *(m-1) # List files modified today.
print *(a1) # List files accessed one day ago.
print *(@) # Print links.
print *(Lk+50) # List files > 50 Kilobytes.
print *(Lk-50) # List files < 50 Kilobytes.
print **/*.c # Recursively list all c files.
print **/*.c~file.c # List all c files, except file.c
print (foo|bar).* # List files whos names start foo or bar.
print *~*.* #
chmod 644 *(.^x) # make all non-executable files publically readable
print -l *(.c|.h) # List all c and header files on their own lines.
print **/*(g:users:) # Recursively list files with the group 'users'
echo /proc/*/cwd(:h:t:s/self//) # Analogue of >ps ax | awk '{print $1}'<"
}
# We can only easily use one documentation directory, so
# these are in priority order
docdirs=(/sw/share/doc /usr/local/share/doc /usr/share/doc)

foreach dir ($docdirs) {
if [[ -d $dir ]] then
doc() { cd $dir/$1 && ls }
gdoc() { cd $dir/$1 && $EDITOR . }
_doc() { _files -W $dir -/ }
break
fi
}

# provide useful information on globbing
H-Glob() {
echo -e "
/ directories
. plain files
@ symbolic links
= sockets
p named pipes (FIFOs)
* executable plain files (0100)
% device files (character or block special)
%b block special files
%c character special files
r owner-readable files (0400)
w owner-writable files (0200)
x owner-executable files (0100)
A group-readable files (0040)
I group-writable files (0020)
E group-executable files (0010)
R world-readable files (0004)
W world-writable files (0002)
X world-executable files (0001)
s setuid files (04000)
S setgid files (02000)
t files with the sticky bit (01000)
print *(m-1) # List files modified today.
print *(a1) # List files accessed one day ago.
print *(@) # Print links.
print *(Lk+50) # List files > 50 Kilobytes.
print *(Lk-50) # List files < 50 Kilobytes.
print **/*.c # Recursively list all c files.
print **/*.c~file.c # List all c files, except file.c
print (foo|bar).* # List files whos names start foo or bar.
print *~*.* #
chmod 644 *(.^x) # make all non-executable files publically readable
print -l *(.c|.h) # List all c and header files on their own lines.
print **/*(g:users:) # Recursively list files with the group 'users'
echo /proc/*/cwd(:h:t:s/self//) # Analogue of >ps ax | awk '{print $1}'<"
}
# vim: set syn=zsh:

0 comments on commit a752ba2

Please sign in to comment.