Skip to content

Commit 7c8e81c

Browse files
authored
Merge pull request #780 from rancher-sandbox/lima
Add LIMA_SHELL env var to lima command
2 parents 2416f5d + b582620 commit 7c8e81c

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

cmd/lima

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/sh
22
set -eu
33
: "${LIMA_INSTANCE:=default}"
4+
: "${LIMA_SHELL:=}"
5+
: "${LIMA_WORKDIR:=}"
46
: "${LIMACTL:=limactl}"
57

68
if [ "$#" -eq 1 ]; then
@@ -11,11 +13,21 @@ if [ "$#" -eq 1 ]; then
1113
echo "${base} is an alias for \"${LIMACTL} shell ${LIMA_INSTANCE}\"."
1214
echo "The instance name (\"${LIMA_INSTANCE}\") can be changed by specifying \$LIMA_INSTANCE."
1315
echo
16+
echo "The shell and initial workdir inside the instance can be specified via \$LIMA_SHELL"
17+
echo "and \$LIMA_WORKDIR."
18+
echo
1419
echo "See \`${LIMACTL} shell --help\` for further information."
1520
exit 0
1621
elif [ "$1" = "-v" ] || [ "$1" = "--version" ]; then
1722
exec "$LIMACTL" "$@"
1823
fi
1924
fi
2025

21-
exec "$LIMACTL" shell "$LIMA_INSTANCE" "$@"
26+
set - "$LIMA_INSTANCE" "$@"
27+
if [ -n "${LIMA_SHELL}" ]; then
28+
set - --shell "$LIMA_SHELL" "$@"
29+
fi
30+
if [ -n "${LIMA_WORKDIR}" ]; then
31+
set - --workdir "$LIMA_WORKDIR" "$@"
32+
fi
33+
exec "$LIMACTL" shell "$@"

docs/internal.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ The directory contains the following files:
7575
- `$LIMA_INSTANCE`: `lima ...` is expanded to `limactl shell ${LIMA_INSTANCE} ...`.
7676
- Default : `default`
7777

78+
- `$LIMA_SHELL`: `lima ...` is expanded to `limactl shell --shell ${LIMA_SHELL} ...`.
79+
- No default : will use the user's shell configured inside the instance
80+
81+
- `$LIMA_WORKDIR`: `lima ...` is expanded to `limactl shell --workdir ${LIMA_WORKDIR} ...`.
82+
- No default : will attempt to use the current directory from the host
83+
7884
- `$QEMU_SYSTEM_X86_64`: path of `qemu-system-x86_64`
7985
- Default: `qemu-system-x86_64` in `$PATH`
8086

0 commit comments

Comments
 (0)