summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--docker-machine/wrapper.sh56
-rw-r--r--p10k.zsh3
-rw-r--r--sh/env.sh4
3 files changed, 63 insertions, 0 deletions
diff --git a/docker-machine/wrapper.sh b/docker-machine/wrapper.sh
new file mode 100644
index 0000000..89aabfa
--- /dev/null
+++ b/docker-machine/wrapper.sh
@@ -0,0 +1,56 @@
+#
+# Function wrapper to docker-machine that adds a use subcommand.
+#
+# The use subcommand runs `eval "$(docker-machine env [args])"`, which is a lot
+# less typing.
+#
+# To enable:
+# 1a. Copy this file somewhere and source it in your .bashrc
+# source /some/where/docker-machine-wrapper.bash
+# 1b. Alternatively, just copy this file into into /etc/bash_completion.d
+#
+# Configuration:
+#
+# DOCKER_MACHINE_WRAPPED
+# When set to a value other than true, this will disable the alias wrapper
+# alias for docker-machine. This is useful if you don't want the wrapper,
+# but it is installed by default by your installation.
+#
+
+: ${DOCKER_MACHINE_WRAPPED:=true}
+
+__docker_machine_wrapper () {
+ if [[ "$1" == use ]]; then
+ # Special use wrapper
+ shift 1
+ case "$1" in
+ -h|--help|"")
+ cat <<EOF
+Usage: docker-machine use [OPTIONS] [arg...]
+
+Evaluate the commands to set up the environment for the Docker client
+
+Description:
+ Argument is a machine name.
+
+Options:
+
+ --swarm Display the Swarm config instead of the Docker daemon
+ --unset, -u Unset variables instead of setting them
+
+EOF
+ ;;
+ *)
+ eval "$(docker-machine env "$@")"
+ echo "Active machine: ${DOCKER_MACHINE_NAME}"
+ ;;
+ esac
+ else
+ # Just call the actual docker-machine app
+ command docker-machine "$@"
+ fi
+}
+
+if [[ ${DOCKER_MACHINE_WRAPPED} = true ]]; then
+ alias docker-machine=__docker_machine_wrapper
+fi
diff --git a/p10k.zsh b/p10k.zsh
index d1966cc..72c1293 100644
--- a/p10k.zsh
+++ b/p10k.zsh
@@ -50,6 +50,7 @@
status # exit code of the last command
command_execution_time # duration of the last command
background_jobs # presence of background jobs
+ docker_machine # active docker machine name
direnv # direnv status (https://direnv.net/)
asdf # asdf version manager (https://github.com/asdf-vm/asdf)
virtualenv # python virtual environment (https://docs.python.org/3/library/venv.html)
@@ -179,6 +180,8 @@
typeset -g POWERLEVEL9K_EMPTY_LINE_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL='%{%}'
fi
+ typeset -g POWERLEVEL9K_DOCKER_MACHINE_FOREGROUND=4
+
#################################[ os_icon: os identifier ]##################################
# OS identifier color.
typeset -g POWERLEVEL9K_OS_ICON_FOREGROUND=
diff --git a/sh/env.sh b/sh/env.sh
index 6b50ad2..4c605e5 100644
--- a/sh/env.sh
+++ b/sh/env.sh
@@ -10,3 +10,7 @@ export MANPAGER="sh -c 'col -bx | bat -l man -p'"
# Path
PATH=$PATH:$HOME/.local/bin:$HOME/.dotnet/tools:$HOME/.cargo/bin:$DOTFILES/scripts
+
+if [ -f "${DOTFILES}/docker-machine/wrapper.sh" ]; then
+ source "${DOTFILES}/docker-machine/wrapper.sh"
+fi