-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlimactl-devshell
More file actions
executable file
·58 lines (49 loc) · 1.98 KB
/
Copy pathlimactl-devshell
File metadata and controls
executable file
·58 lines (49 loc) · 1.98 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh
# <limactl-desc>Enter Lima dev environment from a valid Git worktree. Automatically manages Lima instances for Nix devshell development.</limactl-desc>
#
# ⚠️ REQUIREMENT: Lima >= 2.0.0 (CLI plugins are not available in older versions)
set -eu
# Lima CLI plugin wrapper for lima-devshell
# This allows lima-devshell to be used as: limactl devshell
#
# Installation:
# ln -s /path/to/lima-devshell/limactl-devshell /usr/local/bin/limactl-devshell
# # or install via Home Manager (see README)
# Check Lima version if limactl is available
if command -v limactl >/dev/null 2>&1; then
LIMA_VERSION=$(limactl --version 2>&1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1 || echo "")
if [ -n "$LIMA_VERSION" ]; then
MAJOR_VERSION=$(echo "$LIMA_VERSION" | cut -d. -f1)
if [ "$MAJOR_VERSION" -lt 2 ]; then
echo "limactl-devshell: error: Lima version $LIMA_VERSION detected" >&2
echo "limactl-devshell: CLI plugins require Lima >= 2.0.0" >&2
echo "limactl-devshell: Please upgrade Lima or use 'lima-devshell' command directly" >&2
exit 1
fi
fi
fi
# Find the lima-devshell binary
# Try multiple locations in order of preference:
# 1. Same directory as this script (for development)
# 2. Standard installation paths
# 3. PATH
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
BINARY_NAME="lima-devshell"
# Check if binary is in the same directory as this script
if [ -x "$SCRIPT_DIR/$BINARY_NAME" ]; then
exec "$SCRIPT_DIR/$BINARY_NAME" "$@"
fi
# Try to find in PATH
if command -v "$BINARY_NAME" >/dev/null 2>&1; then
exec "$BINARY_NAME" "$@"
fi
# Try common installation paths
for prefix in /usr/local /opt/homebrew ~/.local; do
if [ -x "$prefix/bin/$BINARY_NAME" ]; then
exec "$prefix/bin/$BINARY_NAME" "$@"
fi
done
# If we get here, binary not found
echo "limactl-devshell: error: lima-devshell binary not found" >&2
echo "limactl-devshell: please install lima-devshell or ensure it's in your PATH" >&2
exit 1