[Bash-completion-devel] wget completion
Freddy Vulto
fvulto at gmail.com
Fri Mar 20 22:20:18 UTC 2009
On Fri, Mar 20, 2009 at 1:22 PM, <gibboris at gmail.com> wrote:
> - I *tried* the completion of the beginning of the host. But I
> can't get the -o nospace working :[
You have to add the `-o nospace' option after `complete' instead of
`compgen'. See diff.
> Another problem is that after 'http', 's://' and '://' ARE
> proposed BUT all is messed up with filename completion if I add a
> ':' (maybe because of the slash or something around $IFS ?).
You can take a look at `scp' completion in file `contrib/ssh' which
already solves processing `:'. Note the: cur=`_get_cword ":"` (?)
I found it difficult though: I tried copying things to wget
but couldn't get it work. Maybe you can give it a try.
> [parenthesis]
> It makes me think : would an algorithm to convert a regexp in
> a completion script like this be useful ?
> ---> (ht|f)tps?://(www.)?
> ---> (h => http, ht => http, f => ftp, http => ( http:// https://),...)
> ---> h) COMPREPLY=( $( compgen -o nospace -W 'http' -- $cur ) );return 0;;...
> [/parenthesis]
Or use bash parameter expansion (see also diff):
COMPREPLY=( $( compgen -W "http{,s}://{,www} ftp://" -- $cur ) )
Regards,
Freddy Vulto
http://fvue.nl
---8<---------------------------------------------------------------
--- wget.sh.orig 2009-03-20 22:20:13.000000000 +0100
+++ wget.sh 2009-03-20 22:55:39.000000000 +0100
@@ -93,23 +93,11 @@
COMPREPLY=( $( compgen -W "$(wget -h | sed -n 's/^[
[:blank:]]*\(-[a-zA-A46]\).*$/\1/p')" -- $cur ) )
return 0
;;
- h)
- COMPREPLY=( $( compgen -o nospace -W 'http' -- $cur ) )
- return 0
- ;;
- f)
- COMPREPLY=( $( compgen -o nospace -W 'ftp://' -- $cur ) )
- return 0
- ;;
- http)
- COMPREPLY=( $( compgen -W 'http:// https://' -- $cur ) )
- return 0
- ;;
- https\?://w)
- COMPREPLY=( $( compgen -W "${cur}ww." -- $cur ) )
+ *)
+ COMPREPLY=( $( compgen -W "http{,s}://{,www} ftp://" -- $cur ) )
return 0
;;
esac
return 0
}
-complete -F _wget -o default wget
+complete -F _wget -o nospace wget
More information about the Bash-completion-devel
mailing list