Skip to content

Commit c294a2f

Browse files
committed
feat ✨ (lima): implement lima shell and install (#42)
Signed-off-by: Luis Mayta <luis@hadenlabs.com>
1 parent 34d2917 commit c294a2f

5 files changed

Lines changed: 57 additions & 3 deletions

File tree

config/base.zsh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
# -*- coding: utf-8 -*-
33

44
export ZSH_DOCKER_PACKAGE_NAME=docker
5-
export ZSH_DOCKER_CONTAINER_APP_NAME="${CONTAINER_APP_NAME:-podman}"
5+
export ZSH_DOCKER_CONTAINER_APP_NAME="${JASPER_CONTAINER_APP_NAME:-lima}"
66
export ZSH_DOCKER_PODMAN_MACHINE_NAME="podman-machine-default"
7+
export ZSH_DOCKER_LIMA_MACHINE_NAME="default"
78
export ZSH_DOCKER_MESSAGE_BREW="Please install brew or use antibody bundle hadenlabs/zsh-brew"
89
export ZSH_DOCKER_MESSAGE_YAY="Please install Go or use antibody bundle hadenlabs/zsh-goenv"
910
export ZSH_DOCKER_MESSAGE_RVM="Please install rvm or use antibody bundle hadenlabs/zsh-rvm"

config/lima.zsh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env ksh
2+
# -*- coding: utf-8 -*-
3+
4+
function container::core {
5+
alias docker='limactl shell default nerdctl'
6+
}

config/main.zsh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ function docker::config::main::factory {
1616
esac
1717

1818
case "${ZSH_DOCKER_CONTAINER_APP_NAME}" in
19-
podman*)
19+
lima*)
20+
# shellcheck source=/dev/null
21+
source "${ZSH_DOCKER_PATH}"/config/lima.zsh
22+
;;
23+
podman*)
2024
# shellcheck source=/dev/null
2125
source "${ZSH_DOCKER_PATH}"/config/podman.zsh
2226
;;

internal/lima.zsh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env ksh
2+
# -*- coding: utf-8 -*-
3+
4+
function container::internal::container::install {
5+
if core::exists lima; then
6+
return
7+
fi
8+
message_info "Installing ${ZSH_DOCKER_PACKAGE_NAME}"
9+
core::install lima
10+
message_success "Installed ${ZSH_DOCKER_PACKAGE_NAME}"
11+
}
12+
13+
function container::internal::container::load {
14+
local machine_name="${ZSH_DOCKER_LIMA_MACHINE_NAME:-default}"
15+
16+
# Check if jq is installed
17+
if ! command -v jq >/dev/null 2>&1; then
18+
echo "❌ 'jq' is required but not installed. Please install it with: brew install jq"
19+
return 1
20+
fi
21+
22+
# Check if the Lima machine exists
23+
if ! limactl list --json | jq -e --arg name "$machine_name" '.[] | select(.name == $name)' >/dev/null; then
24+
echo "🔧 Lima machine '${machine_name}' does not exist. Initializing..."
25+
limactl start "$machine_name"
26+
return
27+
fi
28+
29+
# Check if the machine is running
30+
local running
31+
running=$(limactl list --json | jq -r --arg name "$machine_name" '.[] | select(.name == $name) | .state')
32+
33+
if [[ "$running" != "Running" ]]; then
34+
echo "🚀 Lima machine '${machine_name}' exists but is not running. Starting..."
35+
limactl start "$machine_name"
36+
else
37+
echo "✅ Lima machine '${machine_name}' is already running."
38+
fi
39+
}

internal/main.zsh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ function docker::internal::main::factory {
1616
esac
1717

1818
case "${ZSH_DOCKER_CONTAINER_APP_NAME}" in
19-
podman*)
19+
lima*)
20+
# shellcheck source=/dev/null
21+
source "${ZSH_DOCKER_PATH}"/internal/lima.zsh
22+
;;
23+
podman*)
2024
# shellcheck source=/dev/null
2125
source "${ZSH_DOCKER_PATH}"/internal/podman.zsh
2226
;;

0 commit comments

Comments
 (0)