aboutsummaryrefslogtreecommitdiff
path: root/dbx-run
blob: 2e3535db33b4c9f21d4cd599ce3b2396c0bc78ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env bash
# SPDX-License-Identifier: 0BSD

set -euo pipefail

if [[ $# -lt 1 ]]; then
    echo "ERROR: missing command to run" >&2
    exit 1
fi

c="dbx"
d="$HOME/Developer/dbxroot"

workdir="$(realpath "$PWD")"
if [[ "$workdir" != "$d"* ]]; then
    workdir="$d"
fi

tty="tty"
if [[ ! -t 0 || ! -t 1 ]]; then
    tty="tty=false"
fi

cmd="$1"
shift

podman start "$c" >/dev/null
exec podman exec \
    --detach-keys "" \
    --interactive \
    --"$tty" \
    --user "$(id -u)" \
    --workdir "$workdir" \
    "$c" \
    fish -c "exec '$cmd'"' $argv' -- "$@"