Last active
June 3, 2017 19:59
-
-
Save ginkgomzd/978395dbc75c7969a5562fc29a900d72 to your computer and use it in GitHub Desktop.
make ansible appear as one command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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