-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.bash_env
56 lines (50 loc) · 1.88 KB
/
.bash_env
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
50
51
52
53
54
55
56
# ------------------------------------------------------------------------------
# gms-common bash environment
#
# Add the following line (with an updated path) to your .bashrc:
# source /replace/with/path/to/gms-common/.bash.env
# ------------------------------------------------------------------------------
# Determine the fullpath to the directory containing this file
GMS_COMMON_HOME="$(cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd)"
# Add 'bin' and 'ci' to our PATH
export PATH=${GMS_COMMON_HOME}/bin:${GMS_COMMON_HOME}/ci:${PATH}
# Optonally add 'test/bin' to our PATH if either $GMS_COMMON_INCLUDE_TEST_BIN
# or $GMS_INCLUDE_TEST_BIN is defined
if [ ! -z "${GMS_COMMON_INCLUDE_TEST_BIN}" -o ! -z "${GMS_INCLUDE_TEST_BIN}" ]; then
# NOTE: This is not in the PATH by default since these scripts
# require a correct Python environment to run.
# See python/README.md for more information.
export PATH=${GMS_COMMON_HOME}/test/bin:${PATH}
fi
# Define bash completion for switching between kubernetes clusters
_kubeconfig_completions()
{
if [ "${#COMP_WORDS[@]}" != "2" ]; then
return
fi
if [ -d $HOME/.kube ]; then
for i in $(ls $HOME/.kube/$2*.config 2> /dev/null); do
COMPREPLY+=("$(basename $i .config)")
done
fi
}
complete -F _kubeconfig_completions kubeconfig
kubeconfig()
{
if [ -z "$1" ]; then
for config in $(cd ${HOME}/.kube && ls *.config | sed 's/\.config//'); do
if [[ "${HOME}/.kube/${config}.config" == "${KUBECONFIG}" ]]; then
echo "* ${config}"
else
echo " ${config}"
fi
done
else
if [ -f "${HOME}/.kube/$1.config" ]; then
export KUBECONFIG=${HOME}/.kube/$1.config
else
echo kubeconfig: ${HOME}/.kube/$1.config: No such file
fi
fi
}
source ${GMS_COMMON_HOME}/python/gmskube/bash_completion