Browse Source

nsenter and dive as subcomamnds for docker

master
ojizero 8 months ago
parent
commit
f2b49a1967
2 changed files with 13 additions and 9 deletions
  1. 12
    8
      .docker_shims.zsh
  2. 1
    1
      .zshrc

+ 12
- 8
.docker_shims.zsh View File

@@ -3,7 +3,7 @@ function docker-into {
local _path="${2}"
local args="${3}"

zsh -c "/usr/bin/env docker ${dopts} run -it --rm --volume "${_path}:${_path}" --workdir "${_path}" ${args}"
eval "/usr/bin/env docker ${dopts} run -it --rm --volume "${_path}:${_path}" --workdir "${_path}" ${args}"
}

function docker-build {
@@ -13,7 +13,7 @@ function docker-build {
local default_tag="$(basename ${PWD})"

if [[ "${args}" != *'--help'* ]] || [[ "${args}" != *'-h'* ]]; then
zsh -c "/usr/bin/env docker ${dopts} build ${args}"
eval "/usr/bin/env docker ${dopts} build ${args}"

return $?
fi
@@ -28,7 +28,7 @@ function docker-build {

# TODO: loop and build each named target individually

zsh -c "/usr/bin/env docker ${dopts} build ${args}"
eval "/usr/bin/env docker ${dopts} build ${args}"
}

function docker {
@@ -70,7 +70,7 @@ function docker {
done

if [[ $# -eq 0 ]]; then
zsh -c "/usr/bin/env docker ${dopts} --help"
eval "/usr/bin/env docker ${dopts} --help"

return $?
fi
@@ -86,15 +86,19 @@ function docker {
;;
here) docker-into "${dopts}" "${PWD}" "${@}"
;;
dive) /usr/bin/env docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock wagoodman/dive
;;
nsenter|enter) /usr/bin/env docker run --rm -it --privileged --pid=host justincormack/nsenter1
;;
bld|build) docker-build "${dopts}" "${@}"
;;
net) zsh -c "/usr/bin/env docker ${dopts} network ${@}"
net) eval "/usr/bin/env docker ${dopts} network ${@}"
;;
ctx) zsh -c "/usr/bin/env docker ${dopts} context ${@}"
ctx) eval "/usr/bin/env docker ${dopts} context ${@}"
;;
ls) zsh -c "/usr/bin/env docker ${dopts} images ${@}"
ls) eval "/usr/bin/env docker ${dopts} images ${@}"
;;
*) zsh -c "/usr/bin/env docker ${dopts} ${cmd} ${@}"
*) eval "/usr/bin/env docker ${dopts} ${cmd} ${@}"
;;
esac


+ 1
- 1
.zshrc View File

@@ -28,7 +28,7 @@ eval "$(goenv init -)"
eval "$(rbenv init -)"
eval "$(thefuck --alias)"

source $(dirname $(readlink "${ZSH_PROFILE}"))/.docker_shims.zsh
source "$(dirname $(readlink "${ZSH_PROFILE}"))/.docker_shims.zsh"

# Aliases and functions
#

Loading…
Cancel
Save