PageRenderTime 49ms CodeModel.GetById 40ms app.highlight 1ms RepoModel.GetById 7ms app.codeStats 0ms

/bash_completion.d/pon

http://github.com/brinkman83/bashrc
#! | 51 lines | 39 code | 12 blank | 0 comment | 0 complexity | 41cf8cde5bd9fefe51100a051947b118 MD5 | raw file
 1# Debian GNU/Linux pon/poff(1) completion
 2# Copyright 2002 Baruch Even <baruch@debian.org>
 3# License: GNU GPL v2 or later
 4
 5have pon &&
 6_pon()
 7{
 8	local cur conns
 9    
10	[ -r /etc/ppp/peers/ ] || return 0
11
12	COMPREPLY=()
13	cur=${COMP_WORDS[COMP_CWORD]}
14	conns=$(\ls --color=none /etc/ppp/peers | egrep -v '(\.bak|~)$')
15
16	if [ $COMP_CWORD -eq 1 ]; then
17		COMPREPLY=( $(compgen -o filenames -W "$conns" $cur) )
18	fi
19
20	return 0
21}
22[ "$have" ] && complete -F _pon pon
23
24have poff &&
25_poff()
26{
27	local prev cur conns
28
29	[ -r /etc/ppp/peers/ ] || return 0
30
31	COMPREPLY=()
32	prev=${COMP_WORDS[COMP_CWORD-1]}
33	cur=${COMP_WORDS[COMP_CWORD]}
34	conns=$(\ls --color=none /etc/ppp/peers | egrep -v '(\.bak|~)$')
35
36	if [[ "$cur" == -* ]]; then
37		COMPREPLY=( $(compgen -W '-r -d -c -a -h -v' -- $cur) )
38		return 0
39	fi
40
41	# first parameter on line or first since an option?
42	if [ $COMP_CWORD -eq 1 ] && [[ "$cur" != -* ]] || \
43	  [[ "$prev" == -* ]]; then
44		COMPREPLY=( $(compgen -o filenames -W "$conns" $cur) )
45	fi
46
47	return 0
48}
49[ "$have" ] && complete -F _poff poff
50
51# vim:ft=sh: