-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdockerdevrc
49 lines (37 loc) · 1.45 KB
/
dockerdevrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
##############################################################################
#
# Copyright (c) 2017, 2degrees Limited.
# All Rights Reserved.
#
# This file is part of docker-dev
# <https://github.com/2degrees/docker-dev>, which is subject
# to the provisions of the BSD at
# <http://dev.2degreesnetwork.com/p/2degrees-license.html>. A copy of the
# license should accompany this distribution. THIS SOFTWARE IS PROVIDED "AS IS"
# AND ANY AND ALL EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT
# NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST
# INFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
#
##############################################################################
# ===== Add scripts to $PATH
CURRENT_FILE_PATH="$(realpath --no-symlinks "${BASH_SOURCE}")"
export PATH="${PATH}:$(dirname "${CURRENT_FILE_PATH}")"
unset CURRENT_FILE_PATH
# ===== Autocomplete
function _autocomplete_dockerdev {
local current_word="${COMP_WORDS[COMP_CWORD]}"
COMPREPLY=()
case "${COMP_CWORD}" in
1)
COMPREPLY=( $(compgen -W 'up up2 down run build' -- "${current_word}") )
;;
2)
local subcommand="${COMP_WORDS[1]}"
if [[ "${subcommand}" != "down" ]] ; then
local services="$(docker-compose config --services 2>>/dev/null)"
COMPREPLY=( $(compgen -W "${services}" -- "${current_word}") )
fi
;;
esac
}
complete -F _autocomplete_dockerdev docker-dev