Skip to content

Instantly share code, notes, and snippets.

@ginkgomzd
Last active June 3, 2017 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ginkgomzd/978395dbc75c7969a5562fc29a900d72 to your computer and use it in GitHub Desktop.
Save ginkgomzd/978395dbc75c7969a5562fc29a900d72 to your computer and use it in GitHub Desktop.
make ansible appear as one command
#! /usr/bin/env bash
__print_completions() {
printf '%s\n' "${COMPREPLY[@]}"
}
# load bash-completion functions
source /etc/bash_completion
_ansible_wrapper() {
local params
local ansible
hash "ansible-$1" 2>/dev/null
if [ "$?" -eq "1" ]; then
if [[ "$1" == "adhoc" || "$1" == "ad" || "$1" == "task" ]]; then
ansible='ansible'
else
echo " sorry, ansible-$1 not found";
echo " maybe you meant one of these:"
COMP_LINE='ansible'
COMP_POINT=6
COMP_CWORD=1
_command 2>/dev/null
__print_completions | sort
return 1
fi
else
ansible=ansible-$1
fi
while shift; do
params="$params $1"
done
$ansible $params
}
_ansible_wrapper $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment