766b47d8b85dea53ae6afb64031f6ed9dc271663

Author
Jakub Sacha <jakubsacha@gmail.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Add docker-machine plugin (#4782)

Diff

 1diff --git a/plugins/docker-machine/README.md b/plugins/docker-machine/README.md
 2new file mode 100644
 3index 0000000000000000000000000000000000000000..308a6cfdb608c811b65d7a6f57516d67d018518a
 4--- /dev/null
 5+++ b/plugins/docker-machine/README.md
 6@@ -0,0 +1,19 @@
 7+# docker-machine plugin for oh my zsh
 8+
 9+### Usage
10+
11+#### docker-vm
12+Will create a docker-machine with the name "dev" (required only once)
13+To create a second machine call "docker-vm foobar" or pass any other name
14+
15+#### docker-up
16+This will start your "dev" docker-machine (if necessary) and set it as the active one
17+To start a named machine use "docker-up foobar"
18+
19+#### docker-switch dev
20+Use this to activate a running docker-machine (or to switch between multiple machines)
21+You need to call either this or docker-up when opening a new terminal
22+
23+#### docker-stop
24+This will stop your "dev" docker-machine
25+To stop a named machine use "docker-stop foobar"
26diff --git a/plugins/docker-machine/docker-machine.plugin.zsh b/plugins/docker-machine/docker-machine.plugin.zsh
27new file mode 100644
28index 0000000000000000000000000000000000000000..235d90ee8ff38c413987a69ec3d22d6685c4bc14
29--- /dev/null
30+++ b/plugins/docker-machine/docker-machine.plugin.zsh
31@@ -0,0 +1,33 @@
32+DEFAULT_MACHINE="default"
33+
34+docker-up() {
35+    if [ -z "$1" ]
36+    then
37+        docker-machine start "${DEFAULT_MACHINE}"
38+        eval $(docker-machine env "${DEFAULT_MACHINE}")
39+    else
40+        docker-machine start $1
41+        eval $(docker-machine env $1)
42+    fi
43+    echo $DOCKER_HOST
44+}
45+docker-stop() {
46+    if [ -z "$1" ]
47+    then
48+        docker-machine stop "${DEFAULT_MACHINE}"
49+    else
50+        docker-machine stop $1
51+    fi
52+}
53+docker-switch() {
54+    eval $(docker-machine env $1)
55+    echo $DOCKER_HOST
56+}
57+docker-vm() {
58+    if [ -z "$1" ]
59+    then
60+        docker-machine create -d virtualbox --virtualbox-disk-size 20000 --virtualbox-memory 4096 --virtualbox-cpu-count 2 "${DEFAULT_MACHINE}"
61+    else
62+        docker-machine create -d virtualbox --virtualbox-disk-size 20000 --virtualbox-memory 4096 --virtualbox-cpu-count 2 $1
63+    fi
64+}