This commit is contained in:
Donaldttt
2022-06-18 04:03:23 -04:00
parent 894bbca4fb
commit 340d97c2cb
+22 -6
View File
@@ -32,6 +32,21 @@ dp(){
[ "$debug" = "1" ] && echo $1 [ "$debug" = "1" ] && echo $1
} }
# SHELL specific setting
if [ ! -z "$ZSH_NAME" ]; then
# disable error output when
# wildcard found 0 match
setopt +o nomatch
# show hidden file when using wildcard
# use in fzf_selector
# only for zsh
setopt dotglob
else
# only for bash
shopt -s dotglob
fi
ret='' ret=''
# $1 keyword # $1 keyword
@@ -40,16 +55,15 @@ ret=''
# 1: only show directory # 1: only show directory
fzf_selector() { fzf_selector() {
ret=$1 ret=$1
fchar=(${ret[@]}) if [ "$1" = "." ] || [ "$1" = ".." ] || \
if [ "$1" = "." ] || [ "$1" = ".." ] || [ $fchar = "-" ]; then [[ "$1" == -* ]] || [[ "$1" == */* ]]; then
return 1 return 1
fi fi
shopt -s dotglob
if [ $2 = 0 ]; then if [ $2 = 0 ]; then
all_items=(*) all_items=(*)
elif [ $2 = 1 ]; then elif [ $2 = 1 ]; then
all_items=(*/) all_items=(*/) 2>&1
fi fi
#shopt -u dotglob #shopt -u dotglob
@@ -91,10 +105,11 @@ fzf_command_execute() {
flag="${args[1]}" flag="${args[1]}"
unset 'args[1]' unset 'args[1]'
fi fi
dp "flag: $flag" dp "flag: $flag"
if [ "$len" = "2" ]; then if [ "$len" = "2" ]; then
$args ${args[@]}
return 0 return 0
fi fi
# probably work for bash # probably work for bash
@@ -108,7 +123,8 @@ fzf_command_execute() {
unset 'args[-1]' unset 'args[-1]'
fzf_selector $keyword $flag fzf_selector $keyword $flag
$args "$ret" dp "${args[@]} $ret"
${args[@]} "$ret"
} }
for c in "${fzf_command_list_file[@]}"; do for c in "${fzf_command_list_file[@]}"; do