|
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17 System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64 User : nobody ( 99) PHP Version : 5.2.17 Disable Function : NONE Directory : /usr/share/zsh/4.2.6/functions/ |
Upload File : |
# insert-files() {
# Autoload this function, run `zle -N <func-name>' and bind <func-name>
# to a key.
# This function allows you type a file pattern, and see the results of the
# expansion at each step. When you hit return, they will be inserted into
# the command line.
emulate -L zsh
setopt nobadpattern
local key str files
files=( *(N) )
if (( $#files )); then
zle -R "files: ${str}_" "$files[@]"
else
zle -R "files: ${str}_ (failed)"
fi
read -k key
while [[ '#key' -ne '#\\r' && '#key' -ne '#\\n' &&
'#key' -ne '#\\C-g' ]]; do
if [[ '#key' -eq '#\\C-h' || '#key' -eq '#\\C-?' ]]; then
[[ -n "$str" ]] && str="$str[1,-2]"
else
str="$str$key"
fi
eval "files=( \${~str}*(N) )"
if (( $#files )); then
zle -R "files: ${str}_" "$files[@]"
else
zle -R "files: ${str}_ (failed)"
fi
read -k key
done
zle -Rc
if [[ '#key' -ne '#\\C-g' && $#files -gt 0 ]]; then
[[ "$LBUFFER[-1]" = ' ' ]] || files=('' "$files[@]")
LBUFFER="$LBUFFER$files "
fi
# }