blob: 17aff4ea4eda28f27089e0bae65bb61b3e8eb05a [file] [log] [blame]
Fedyashev Nikita4350c3f2010-11-18 23:42:30 -05001#!/bin/bash
2_vagrant()
3{
Fedyashev Nikita4350c3f2010-11-18 23:42:30 -05004 cur="${COMP_WORDS[COMP_CWORD]}"
5 prev="${COMP_WORDS[COMP_CWORD-1]}"
Fedyashev Nikita7f721fe2010-11-19 00:27:14 -05006 commands="box destroy halt help init package provision reload resume ssh ssh_config status suspend up version"
Fedyashev Nikita4350c3f2010-11-18 23:42:30 -05007
Fedyashev Nikita5f6125e2010-11-19 00:22:13 -05008 if [ $COMP_CWORD == 1 ]
9 then
Fedyashev Nikita5f6125e2010-11-19 00:22:13 -050010 COMPREPLY=($(compgen -W "${commands}" -- ${cur}))
11 return 0
12 fi
Fedyashev Nikita4350c3f2010-11-18 23:42:30 -050013
Fedyashev Nikita5f6125e2010-11-19 00:22:13 -050014 if [ $COMP_CWORD == 2 ]
15 then
Fedyashev Nikita7f721fe2010-11-19 00:27:14 -050016 case "$prev" in
17 "box")
18 box_commands="add help list remove repackage"
19 COMPREPLY=($(compgen -W "${box_commands}" -- ${cur}))
20 return 0
21 ;;
22 "help")
23 COMPREPLY=($(compgen -W "${commands}" -- ${cur}))
24 return 0
25 ;;
26 *)
27 ;;
28 esac
Fedyashev Nikita5f6125e2010-11-19 00:22:13 -050029 fi
30
31 if [ $COMP_CWORD == 3 ]
32 then
33 action="${COMP_WORDS[COMP_CWORD-2]}"
34 if [ $action == 'box' ]
35 then
36 case "$prev" in
37 "remove"|"repackage")
Fedyashev Nikita7f721fe2010-11-19 00:27:14 -050038 local box_list=$(find $HOME/.vagrant/boxes/* -maxdepth 0 -type d -printf '%f ')
39 COMPREPLY=($(compgen -W "${box_list}" -- ${cur}))
Fedyashev Nikita5f6125e2010-11-19 00:22:13 -050040 return 0
41 ;;
42 *)
43 ;;
44 esac
45 fi
46 fi
47
Fedyashev Nikita4350c3f2010-11-18 23:42:30 -050048}
49complete -F _vagrant vagrant
Fedyashev Nikita4350c3f2010-11-18 23:42:30 -050050