mirror of
https://github.com/chenasraf/dotfiles.git
synced 2026-05-17 17:28:07 +00:00
feat: add docker-volume-(path|cd) commands
fix: rename _docker_completions to _docker-exec
This commit is contained in:
@@ -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
15
completions/_docker-volume-path
Executable 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
|
||||
26
functions.sh
26
functions.sh
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user