mirror of
https://github.com/DictXiong/dotfiles.git
synced 2024-11-24 09:47:00 +08:00
Dict Xiong
6e33fc0875
* dogo/doll dogo supports zsh/bash/sh; doll is introduced to launch a new docker container; update $SUDO in command.sh * update ci * fix regex * dogo: enhance, support -[0-9]* * dogo&doll: enhanced * zshrc: sibd and sob
26 lines
663 B
Bash
Executable File
26 lines
663 B
Bash
Executable File
#!/bin/bash
|
|
|
|
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
|
|
source "$THIS_DIR/../tools/common.sh"
|
|
|
|
DOCKER_FORMAT="{{.ID}} {{.Repository}}:{{.Tag}}"
|
|
if [[ -z "$1" || "$1" =~ ^(-h|--help)$ ]]; then
|
|
fmt_info "usage: $0 <image> or -[0-9]*"
|
|
exit
|
|
elif [[ "$1" =~ ^-[0-9]*$ ]]; then
|
|
LAST="${1:1}"
|
|
# the last nth image
|
|
IMAGE_META=($($SUDO docker image ls --format "$DOCKER_FORMAT" | head -n ${LAST:-1} | tail -n 1))
|
|
IMAGE=${IMAGE_META[0]}
|
|
else
|
|
IMAGE_META="$1"
|
|
IMAGE="$1"
|
|
fi
|
|
|
|
if [[ -z "$IMAGE" ]]; then
|
|
fmt_error "image not found"
|
|
else
|
|
echo "--> ${IMAGE_META[@]}"
|
|
echo $SUDO docker run -itd $IMAGE sh
|
|
fi
|