diff --git a/CHANGES b/CHANGES index 83902b55..fa4e7c61 100644 --- a/CHANGES +++ b/CHANGES @@ -15,7 +15,7 @@ bash-completion (1.x) * Apply cardctl completion to pccardctl too. * Apply pine completion to alpine too. * Remove many unnecessary short option completions where long ones exist. - * Improve cvs, gkrellm, mdadm, and mysqladmin completions. + * Improve cvs, gkrellm, lftp, mdadm, and mysqladmin completions. * Add wtf completion, based on work by Raphaƫl Droz. * Add lftpget completion. diff --git a/contrib/lftp b/contrib/lftp index a96d9337..7901a70b 100644 --- a/contrib/lftp +++ b/contrib/lftp @@ -3,20 +3,33 @@ have lftp && _lftp() { - local cur + local cur prev COMPREPLY=() cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} - if [ $COMP_CWORD -eq 1 ] && [ -f ~/.lftp/bookmarks ]; then - COMPREPLY=( $( compgen -W '$( sed -ne "s/^\(.*\)'$'\t''.*$/\1/p" \ - ~/.lftp/bookmarks )' -- "$cur" ) ) + case "$prev" in + -f) + _filedir + return 0 + ;; + -c|-h|--help|-v|--version|-e|-u|-p) + return 0 + ;; + esac + + if [[ "$cur" == -* ]] ; then + COMPREPLY=( $( compgen -W '-f -c --help --version -e -u -p' \ + -- "$cur" ) ) + return 0 fi - return 0 + COMPREPLY=( $( compgen -W \ + '$( cut -f 1 -s ~/.lftp/bookmarks 2>/dev/null )' -- "$cur" ) ) + _known_hosts_real "$cur" } && -complete -F _lftp $default lftp - +complete -F _lftp $filenames lftp have lftpget && _lftpget() {