feat: add docker-volume-(path|cd) commands

fix: rename _docker_completions to _docker-exec
This commit is contained in:
2023-02-03 22:02:57 +00:00
parent e6f2273684
commit b7f0be95c5
4 changed files with 41 additions and 4 deletions

View File

@@ -67,6 +67,10 @@ alias dlog="docker-log"
alias dbash="docker-bash"
alias db="docker-bash"
alias dsh="docker-sh"
alias dvolc="docker-volume-cd"
alias dvc="docker-volume-cd"
alias dvolp="docker-volume-path"
alias dvp="docker-volume-path"
if is_linux; then
alias md5="md5sum"

15
completions/_docker-volume-path Executable file
View File

@@ -0,0 +1,15 @@
#compdef docker-volume-path docker-volume-cd
names=($(docker volume ls | tail --line=+2 | awk '{ print $2 }'))
if [[ -z $names ]]; then
return 1
fi
out=()
for i in $names; do
out+=("$i")
done
_describe 'volume' out

View File

@@ -111,10 +111,15 @@ src() {
return 1
fi
file="$DOTFILES/$1.sh"
if [[ -f "$DOTFILES/$1.sh" ]]; then
file="$DOTFILES/$1.sh"
else
file="$DOTFILES/$1"
fi
if [[ -f $file ]]; then
echo "Reloading $DOTFILES/$1.sh..."
source "$DOTFILES/$1.sh"
echo "Reloading $file..."
source "$file"
return 0
fi
echo_red "File not found: $file"
@@ -238,4 +243,17 @@ docker-sh() {
docker-exec "$image" /bin/sh $@
}
autoload _docker_completions
docker-volume-path() {
image="$1"
shift
docker volume inspect "$image" | jq -r '.[0].Mountpoint'
}
docker-volume-cd() {
image="$1"
shift
cd $(docker-volume-path "$image")
}
autoload _docker-exec
autoload _docker-volume-path