mirror of
https://github.com/chenasraf/dotfiles.git
synced 2026-05-17 17:28:07 +00:00
chore: cleanups & extract docker cmds
This commit is contained in:
2
.zshrc
2
.zshrc
@@ -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]
|
||||
|
||||
@@ -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
46
plugins/docker.plugin.zsh
Normal 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")
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user