blob: d7815e520cb61912062c218f30a851113ec9e1f4 (
plain) (
blame)
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
|
#
# bash prompt support for docker-machine
#
# This script allows you to see the active machine in your bash prompt.
#
# To enable:
# 1a. Copy this file somewhere and source it in your .bashrc
# source /some/where/docker-machine-prompt.bash
# 1b. Alternatively, just copy this file into into /etc/bash_completion.d
# 2. Change your PS1 to call __docker-machine-ps1 as command-substitution
# PS1='[\u@\h \W$(__docker_machine_ps1 " [%s]")]\$ '
#
# Configuration:
#
# DOCKER_MACHINE_PS1_SHOWSTATUS
# When set, the machine status is indicated in the prompt. This can be slow,
# so use with care.
#
__docker_machine_ps1 () {
local format=${1:- [%s]}
if test ${DOCKER_MACHINE_NAME}; then
local machine_status=''
if test ${DOCKER_MACHINE_PS1_SHOWSTATUS:-false} = true; then
machine_status=$(docker-machine status ${DOCKER_MACHINE_NAME})
case ${machine_status} in
Running)
machine_status=' R'
;;
Stopping)
machine_status=' R->S'
;;
Starting)
machine_status=' S->R'
;;
Error|Timeout)
machine_status=' E'
;;
*)
# Just consider everything elase as 'stopped'
machine_status=' S'
;;
esac
fi
printf -- "${format}" "${DOCKER_MACHINE_NAME}${machine_status}"
fi
}
|