Skip to content

Commit

Permalink
🚢 docker-run
Browse files Browse the repository at this point in the history
  • Loading branch information
juftin committed Nov 19, 2024
1 parent b61780d commit 5903522
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
51 changes: 51 additions & 0 deletions bin/docker-run
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env bash

set -euo pipefail

GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m'

if [ $# -lt 1 ]; then
echo -e "${GREEN}Usage:${NC} ${BLUE}docker-run <IMAGE> [<DOCKER-ARGS>] -- <COMMAND>${NC}"
exit 1
fi

IMAGE="${1}"
shift

DOCKER_ARGS=()
COMMAND=()

DOCKER_ARGS+=(
"--rm"
"-it"
"--env" "TERM=xterm-256color"
"--env" "COLORTERM=truecolor"
"--volume" "${PWD}:/work/${PWD##*/}"
"--workdir" "/work/${PWD##*/}"
)

PARSING_COMMAND=false
while [ $# -gt 0 ]; do
if [ "$1" = "--" ]; then
PARSING_COMMAND=true
shift
continue
fi
if [ "$PARSING_COMMAND" = true ]; then
COMMAND+=("$1")
else
DOCKER_ARGS+=("$1")
fi
shift
done

if [ ${#COMMAND[@]} -eq 0 ]; then
DOCKER_RUN_COMMAND="docker run ${DOCKER_ARGS[*]} ${IMAGE}"
else
DOCKER_RUN_COMMAND="docker run ${DOCKER_ARGS[*]} ${IMAGE} ${COMMAND[*]}"
fi

echo -e "${GREEN}Docker Command:${NC} ${BLUE}${DOCKER_RUN_COMMAND}${NC}"
eval "${DOCKER_RUN_COMMAND}"
4 changes: 3 additions & 1 deletion git/.gitconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
[core]
excludesfile = ~/.gitignore
[alias]
dunk = !git diff HEAD | dunk | less -R
dunk = !git add --all --intent-to-add && git diff HEAD | dunk | less -R --mouse --wheel-lines=3
[filter "lfs"]
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
clean = git-lfs clean -- %f
[credential "https://github.com"]
helper =
helper = !gh auth git-credential
[credential "https://gist.github.com"]
helper =
helper = !gh auth git-credential
3 changes: 3 additions & 0 deletions tools/vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
Expand Down

0 comments on commit 5903522

Please sign in to comment.