chore: cleanups & extract docker cmds

This commit is contained in:
2024-08-08 10:34:34 +03:00
parent deb12c8730
commit 609da065b6
4 changed files with 48 additions and 49 deletions

2
.zshrc
View File

@@ -6,7 +6,7 @@ export DOTBIN_META="$HOME/.config/.bin"
source "$HOME/.dotfiles/plugins/functions.plugin.zsh"
source "$DOTFILES/exports.zsh"
[[ "$1" == "-q" ]] || motd
[[ "$1" == "-q" ]] || run-parts "$DOTFILES/plugins/motd"
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]

View File

@@ -111,6 +111,7 @@ alias hlog="home git log"
alias hiv="hi; vim ."
alias hv="pushd \$(wd path df); vi .; popd"
alias spider="ssh root@spider.casraf.dev"
alias motd="run-parts \$DOTFILES/plugins/motd"
# docker
alias de="docker-exec"

46
plugins/docker.plugin.zsh Normal file
View File

@@ -0,0 +1,46 @@
#!/usr/bin/env zsh
# open docker logs for specified container
docker-log() {
image="$1"
shift
docker logs --follow $@ "$image"
}
# docker exec command for specified container
docker-exec() {
image="$1"
executable="$2"
shift 2
rest=$@
docker exec -ti $rest "$image" "$executable"
}
# open docker bash shell for specified container
docker-bash() {
image="$1"
shift
docker-exec "$image" /bin/bash $@
}
# open docker sh shell for specified container
docker-sh() {
image="$1"
shift
docker-exec "$image" /bin/sh $@
}
# get path of docker volume
docker-volume-path() {
image="$1"
shift
docker volume inspect "$image" | jq -r '.[0].Mountpoint'
}
# cd to docker volume
docker-volume-cd() {
image="$1"
shift
cd $(docker-volume-path "$image")
}

View File

@@ -2,10 +2,6 @@
source $DOTFILES/autoload_completions.zsh
motd() {
run-parts $DOTFILES/plugins/motd
}
# Functions
# show all man entries under a specific section
@@ -201,50 +197,6 @@ prj() {
popd
}
# open docker logs for specified container
docker-log() {
image="$1"
shift
docker logs --follow $@ "$image"
}
# docker exec command for specified container
docker-exec() {
image="$1"
executable="$2"
shift 2
rest=$@
docker exec -ti $rest "$image" "$executable"
}
# open docker bash shell for specified container
docker-bash() {
image="$1"
shift
docker-exec "$image" /bin/bash $@
}
# open docker sh shell for specified container
docker-sh() {
image="$1"
shift
docker-exec "$image" /bin/sh $@
}
# get path of docker volume
docker-volume-path() {
image="$1"
shift
docker volume inspect "$image" | jq -r '.[0].Mountpoint'
}
# cd to docker volume
docker-volume-cd() {
image="$1"
shift
cd $(docker-volume-path "$image")
}
# reload entire shell
reload-zsh() {
source $HOME/.zshrc