zsh-workers
 help / color / mirror / code / Atom feed
10f90ed4a0449161a35fdab80a2a388d53db3af4 blob 997 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
 
# 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
# }
debug log:

solving 10f90ed4a ...
found 10f90ed4a in https://git.vuxu.org/mirror/zsh/

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).