[bash/zsh-completion] List hidden files as well

Close #456 and #457
This commit is contained in:
Junegunn Choi 2015-12-29 00:00:20 +09:00
parent c8a3f6f06a
commit e1dd798482
3 changed files with 21 additions and 9 deletions

View File

@ -110,9 +110,9 @@ __fzf_generic_path_completion() {
if [ -z "$dir" -o -d "$dir" ]; then
leftover=${base/#"$dir"}
leftover=${leftover/#\/}
[ "$dir" = './' ] && dir=''
[ -z "$dir" ] && dir='.' || dir="${dir/%\//}"
tput sc
matches=$(find -L "$dir"* $1 2> /dev/null | $fzf $FZF_COMPLETION_OPTS $2 -q "$leftover" | while read item; do
matches=$(\find -L "$dir" $1 -a -not -path "$dir" -print 2> /dev/null | sed 's@^\./@@' | $fzf $FZF_COMPLETION_OPTS $2 -q "$leftover" | while read item; do
printf "%q$3 " "$item"
done)
matches=${matches% }
@ -171,19 +171,19 @@ _fzf_complete() {
_fzf_path_completion() {
__fzf_generic_path_completion \
"-name .git -prune -o -name .svn -prune -o -type d -print -o -type f -print -o -type l -print" \
"-name .git -prune -o -name .svn -prune -o ( -type d -o -type f -o -type l )" \
"-m" "" "$@"
}
_fzf_file_completion() {
__fzf_generic_path_completion \
"-name .git -prune -o -name .svn -prune -o -type f -print -o -type l -print" \
"-name .git -prune -o -name .svn -prune -o ( -type f -o -type l )" \
"-m" "" "$@"
}
_fzf_dir_completion() {
__fzf_generic_path_completion \
"-name .git -prune -o -name .svn -prune -o -type d -print" \
"-name .git -prune -o -name .svn -prune -o -type d" \
"" "/" "$@"
}

View File

@ -30,9 +30,9 @@ __fzf_generic_path_completion() {
if [ -z "$dir" -o -d ${~dir} ]; then
leftover=${base/#"$dir"}
leftover=${leftover/#\/}
[ "$dir" = './' ] && dir=''
[ -z "$dir" ] && dir='.' || dir="${dir/%\//}"
dir=${~dir}
matches=$(\find -L $dir* ${=find_opts} 2> /dev/null | ${=fzf} ${=FZF_COMPLETION_OPTS} ${=fzf_opts} -q "$leftover" | while read item; do
matches=$(\find -L "$dir" ${=find_opts} -a -not -path "$dir" -print 2> /dev/null | sed 's@^\./@@' | ${=fzf} ${=FZF_COMPLETION_OPTS} ${=fzf_opts} -q "$leftover" | while read item; do
printf "%q$suffix " "$item"
done)
matches=${matches% }
@ -50,13 +50,13 @@ __fzf_generic_path_completion() {
_fzf_path_completion() {
__fzf_generic_path_completion "$1" "$2" \
"-name .git -prune -o -name .svn -prune -o -type d -print -o -type f -print -o -type l -print" \
"-name .git -prune -o -name .svn -prune -o ( -type d -o -type f -o -type l )" \
"-m" "" " "
}
_fzf_dir_completion() {
__fzf_generic_path_completion "$1" "$2" \
"-name .git -prune -o -name .svn -prune -o -type d -print" \
"-name .git -prune -o -name .svn -prune -o -type d" \
"" "/" ""
}

View File

@ -1071,6 +1071,8 @@ module CompletionTest
tmux.prepare
tmux.send_keys 'cat /tmp/fzf-test/10**', :Tab, pane: 0
tmux.until(1) { |lines| lines.item_count > 0 }
tmux.send_keys ' !d'
tmux.until(1) { |lines| lines[-2].include?(' 2/') }
tmux.send_keys :BTab, :BTab
tmux.until(1) { |lines| lines[-2].include?('(2)') }
tmux.send_keys :Enter
@ -1111,6 +1113,16 @@ module CompletionTest
tmux.send_keys 'C-L'
lines[-1].end_with?('/tmp/fzf\ test/foobar')
end
# Should include hidden files
(1..100).each { |i| FileUtils.touch "/tmp/fzf-test/.hidden-#{i}" }
tmux.send_keys 'C-u'
tmux.send_keys 'cat /tmp/fzf-test/hidden**', :Tab, pane: 0
tmux.until(1) do |lines|
tmux.send_keys 'C-L'
lines[-2].include?('100/') &&
lines[-3].include?('/tmp/fzf-test/.hidden-')
end
ensure
['/tmp/fzf-test', '/tmp/fzf test', '~/.fzf-home', 'no~such~user'].each do |f|
FileUtils.rm_rf File.expand_path(f)