trying to autocomp with spaces...

This commit is contained in:
Q
2022-10-17 22:18:15 +03:00
parent 0aa277a921
commit 40fed6563f

View File

@@ -39,7 +39,7 @@ Get autocomplete:
Config: Config:
CCLIP_HOME environment variable sets clipboard storage folder, CCLIP_HOME environment variable sets clipboard storage folder,
defauls to ~/.cache/cclip defauls to ~/.cache/cclip
" "
exit exit
} }
@@ -364,10 +364,10 @@ _err() {
} }
_gui() { _gui() {
# GUI is intended for mc (midnight commander) # GUI is intended for mc (midnight commander)
# Example menu config # Example menu config
# 5 cclip # 5 cclip
# cclip mc %s # cclip mc %s
CLIPBOARD=mc CLIPBOARD=mc
fileargs=$(( $# - 1 )) fileargs=$(( $# - 1 ))
@@ -422,7 +422,7 @@ Options:
d keep clipboard: %s d keep clipboard: %s
e exit e exit
Toggle option:\n" "$movelink" "$softlink" "$hardlink" "$keeplink" Toggle option:\n" "$movelink" "$softlink" "$hardlink" "$keeplink"
read -s -n 1 optkey read -s -n 1 optkey
case "$optkey" in case "$optkey" in
@@ -430,7 +430,7 @@ Toggle option:\n" "$movelink" "$softlink" "$hardlink" "$keeplink"
s) softlink=$(( 1 - softlink )) ;; s) softlink=$(( 1 - softlink )) ;;
l) hardlink=$(( 1 - hardlink )) ;; l) hardlink=$(( 1 - hardlink )) ;;
d) keeplink=$(( 1 - keeplink )) ;; d) keeplink=$(( 1 - keeplink )) ;;
e) break;; e) break ;;
esac esac
done done
@@ -441,25 +441,30 @@ _get_completer() {
local curr_arg local curr_arg
curr_arg=${COMP_WORDS[COMP_CWORD]} curr_arg=${COMP_WORDS[COMP_CWORD]}
if [[ $COMP_CWORD -eq 1 ]]; then if [[ $COMP_CWORD -eq 1 ]]; then
COMPREPLY=( $(compgen -W "help autocomplete l list c copy p paste delete Delete" -- $curr_arg ) ); COMPREPLY=( $(compgen -W "help autocomplete l list c copy p paste delete Delete" -- "$curr_arg" ) );
fi fi
if [[ $COMP_CWORD -eq 2 ]]; then if [[ $COMP_CWORD -eq 2 ]]; then
case ${COMP_WORDS[$(( $COMP_CWORD - 1 ))]} in case ${COMP_WORDS[1]} in
p|paste|d*|e|edit|rm|remove) d*|e|edit|rm|remove)
local IFS=$'"'"'\n'"'"' local IFS=$'"'"'\n'"'"'
local remotelist=( $( eval CCLIP_EXEC simplelist ) ) local remotelist=( $( eval CCLIP_EXEC simplelist ) )
COMPREPLY=( $(compgen -W "${remotelist[*]}" -- $curr_arg ) ); COMPREPLY=( $(compgen -W "${remotelist[*]}" -- "$curr_arg" ) );
;;
p|paste)
local IFS=$'"'"'\n'"'"'
local remotelist=( $( eval CCLIP_EXEC simplelist ) )
COMPREPLY=( $(compgen -W "${remotelist[*]}" -- "$curr_arg" ) );
;; ;;
c*) c*)
COMPREPLY=( $(compgen -f -d -X '' -- $curr_arg ) ); COMPREPLY=();
;; ;;
esac esac
fi fi
} }
complete -F _CCLIP_EXEC_complete CCLIP_EXEC complete -o bashdefault -o default -o nospace -F _CCLIP_EXEC_complete CCLIP_EXEC
# Run me as: source <( CCLIP_EXEC autocomplete ) # Run me as: source <( CCLIP_EXEC autocomplete )
' | sed "s,CCLIP_EXEC,$self,g" ' | sed "s,CCLIP_EXEC,$self,g"
exit 0 exit 0
} }
_qCol() { _qCol() {