Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: mitchellh/vagrant
...
head fork: rafmagana/vagrant
compare: bash_completion
Checking mergeability… Don't worry, you can still create the pull request.
  • 1 commit
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Commits on Apr 10, 2012
@rafmagana rafmagana simple bash completion da57aae
Showing with 131 additions and 0 deletions.
  1. +131 −0 scripts/bash_completion.sh
View
131 scripts/bash_completion.sh
@@ -0,0 +1,131 @@
+#!/usr/bin/env bash
+
+# bash completion for Vagrant
+
+HELP='-h --help'
+
+FLAGS='${HELP} -v --version'
+
+__vagrant_generate_completion()
+{
+ typeset current_word
+ current_word="${COMP_WORDS[COMP_CWORD]}"
+
+ COMPREPLY=( $(compgen -W "$1" -- "${current_word}") )
+ return 0
+}
+
+__vagrant_command ()
+{
+ typeset current_word
+ current_word="${COMP_WORDS[COMP_CWORD]}"
+
+ case "${current_word}" in
+ -*) __vagrant_flags ;;
+ *) __vagrant_subcommands ;;
+ esac
+}
+__vagrant_subcommands ()
+{
+ SUBCOMMANDS='\
+ box destroy gem halt init\
+ init package provision reload\
+ resume ssh ssh-config status\
+ suspend up'
+
+ __vagrant_generate_completion "$SUBCOMMANDS $FLAGS"
+}
+
+__vagrant_flags ()
+{
+ __vagrant_generate_completion "$FLAGS"
+}
+
+__vagrant_box_list ()
+{
+ echo "`vagrant box list`"
+}
+
+__vagrant_box ()
+{
+ COMMANDS='add list remove repackage'
+
+ __vagrant_generate_completion "$COMMANDS $HELP"
+}
+
+__vagrant_init ()
+{
+ __vagrant_generate_completion "$(__vagrant_box_list) $HELP"
+}
+
+__vagrant_up ()
+{
+ OPTIONS='--no-provision --provision --provision-with'
+
+ __vagrant_generate_completion "$OPTIONS $HELP"
+}
+
+__vagrant_ssh ()
+{
+ OPTIONS='-c --command -p --plain'
+
+ __vagrant_generate_completion "$OPTIONS $HELP"
+}
+
+__vagrant_destroy ()
+{
+ OPTIONS='-f --force'
+
+ __vagrant_generate_completion "$OPTIONS $HELP"
+}
+
+__vagrant_halt ()
+{
+ OPTIONS='-f --force'
+
+ __vagrant_generate_completion "$OPTIONS $HELP"
+}
+
+__vagrant_package ()
+{
+ OPTIONS='--base --output --include --vagrantfile'
+
+ __vagrant_generate_completion "$OPTIONS $HELP"
+}
+
+__vagrant_reload ()
+{
+ OPTIONS='--no-provision --provision --provision-with'
+
+ __vagrant_generate_completion "$OPTIONS $HELP"
+}
+
+__vagrant_ssh_config ()
+{
+ OPTIONS='--host'
+
+ __vagrant_generate_completion "$OPTIONS $HELP"
+}
+
+__vagrant ()
+{
+ typeset previous_word
+ previous_word="${COMP_WORDS[COMP_CWORD-1]}"
+
+ case "${previous_word}" in
+ box) __vagrant_box ;;
+ destroy) __vagrant_destroy ;;
+ halt) __vagrant_halt ;;
+ init) __vagrant_init ;;
+ package) __vagrant_package ;;
+ reload) __vagrant_reload ;;
+ ssh) __vagrant_ssh ;;
+ ssh-config) __vagrant_ssh_config ;;
+ up) __vagrant_up ;;
+ *) __vagrant_command ;;
+ esac
+
+ return 0
+}
+
+complete -o default -o nospace -F __vagrant vagrant

No commit comments for this range

Something went wrong with that request. Please try again.