mirror of
https://github.com/DictXiong/dotfiles.git
synced 2025-12-19 20:47:49 +08:00
23 lines
666 B
Bash
Executable File
23 lines
666 B
Bash
Executable File
#!/bin/bash
|
|
|
|
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
|
|
source "$THIS_DIR/../tools/common.sh"
|
|
|
|
|
|
if [[ -z "$1" || "$1" =~ ^(-h|--help)$ ]]; then
|
|
fmt_info "usage: $0 <container> or -[0-9]*"
|
|
exit
|
|
elif [[ "$1" =~ ^-[0-9]*$ ]]; then
|
|
LAST="${1:1}"
|
|
CONTAINER=$(docker container ls -qn ${LAST:-1} | tail -n 1)
|
|
else
|
|
CONTAINER="$1"
|
|
fi
|
|
|
|
if [[ -z "$CONTAINER" ]]; then
|
|
fmt_error "container not found"
|
|
else
|
|
echo "--> $CONTAINER"
|
|
$SUDO docker exec -it $CONTAINER sh -c 'if [ -x "$(command -v zsh)" ]; then echo "--> zsh"; zsh; elif [ -x "$(command -v bash)" ]; then echo "--> bash"; bash; else echo "--> sh"; sh; fi'
|
|
fi
|