Skip to content

Commit f019a43

Browse files
jsburckhardtCopilot
andcommitted
feat: add yazi terminal file manager dev container feature
Adds yazi (https://github.com/sxyazi/yazi) as a new dev container feature. Installs both yazi and ya binaries from GitHub releases with multi-architecture support (x86_64, aarch64, i686). Co-authored-by: Copilot <[email protected]>
1 parent bf1ed40 commit f019a43

7 files changed

Lines changed: 156 additions & 1 deletion

File tree

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ This repository contains a _collection_ of Features.
2929
| OpenCode | https://opencode.ai/ | AI coding agent, built for the terminal. An open-source alternative to Claude Code with support for multiple LLM providers. |
3030
| Codex-cli | https://github.com/openai/codex | Codex CLI is an experimental project under active development. |
3131
| ccc | https://github.com/jsburckhardt/co-config | A TUI tool to interactively configure and view GitHub Copilot CLI settings. |
32+
| Yazi | https://github.com/sxyazi/yazi | Blazing fast terminal file manager written in Rust, based on async I/O. |
3233

3334

3435

@@ -355,3 +356,20 @@ Running `ccc` inside the built container will print the version of ccc (Copilot
355356
```bash
356357
ccc --version
357358
```
359+
360+
### `yazi`
361+
362+
Running `yazi --version` inside the built container will print the version of yazi.
363+
364+
```jsonc
365+
{
366+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
367+
"features": {
368+
"ghcr.io/jsburckhardt/devcontainer-features/yazi:1": {}
369+
}
370+
}
371+
```
372+
373+
```bash
374+
yazi --version
375+
```

src/yazi/devcontainer-feature.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "Yazi",
3+
"id": "yazi",
4+
"version": "1.0.0",
5+
"description": "Blazing fast terminal file manager written in Rust, based on async I/O.",
6+
"options": {
7+
"version": {
8+
"type": "string",
9+
"default": "latest",
10+
"description": "Version of yazi to install from GitHub releases e.g. v26.1.22"
11+
}
12+
}
13+
}

src/yazi/install.sh

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#!/usr/bin/env bash
2+
3+
# Variables
4+
REPO_OWNER="sxyazi"
5+
REPO_NAME="yazi"
6+
BINARY_NAME="yazi"
7+
YAZI_VERSION="${VERSION:-"latest"}"
8+
GITHUB_API_REPO_URL="https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/releases"
9+
10+
set -e
11+
12+
if [ "$(id -u)" -ne 0 ]; then
13+
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
14+
exit 1
15+
fi
16+
17+
# Clean up
18+
rm -rf /var/lib/apt/lists/*
19+
20+
# Checks if packages are installed and installs them if not
21+
check_packages() {
22+
if ! dpkg -s "$@" >/dev/null 2>&1; then
23+
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
24+
echo "Running apt-get update..."
25+
apt-get update -y
26+
fi
27+
apt-get -y install --no-install-recommends "$@"
28+
fi
29+
}
30+
31+
# Make sure we have curl, jq, and unzip
32+
check_packages curl jq ca-certificates unzip
33+
34+
# Function to get the latest version from GitHub API
35+
get_latest_version() {
36+
curl -s "${GITHUB_API_REPO_URL}/latest" | jq -r ".tag_name"
37+
}
38+
39+
# Check if a version is passed as an argument
40+
if [ -z "$YAZI_VERSION" ] || [ "$YAZI_VERSION" == "latest" ]; then
41+
YAZI_VERSION=$(get_latest_version)
42+
echo "No version provided or 'latest' specified, installing the latest version: $YAZI_VERSION"
43+
else
44+
echo "Installing version from environment variable: $YAZI_VERSION"
45+
fi
46+
47+
# Determine the OS and architecture
48+
ARCH=$(uname -m)
49+
50+
case "$ARCH" in
51+
x86_64)
52+
ARCH="x86_64"
53+
;;
54+
aarch64)
55+
ARCH="aarch64"
56+
;;
57+
i686)
58+
ARCH="i686"
59+
;;
60+
*)
61+
echo "Unsupported architecture: $ARCH"
62+
exit 1
63+
;;
64+
esac
65+
66+
# Construct the download URL
67+
# Asset pattern: yazi-{ARCH}-unknown-linux-gnu.zip
68+
ASSET_NAME="${BINARY_NAME}-${ARCH}-unknown-linux-gnu"
69+
DOWNLOAD_URL="https://github.com/${REPO_OWNER}/${REPO_NAME}/releases/download/${YAZI_VERSION}/${ASSET_NAME}.zip"
70+
71+
# Create a temporary directory for the download
72+
TMP_DIR=$(mktemp -d)
73+
cd "$TMP_DIR" || exit
74+
75+
echo "Downloading $BINARY_NAME from $DOWNLOAD_URL"
76+
curl -sSL "$DOWNLOAD_URL" -o "${BINARY_NAME}.zip"
77+
78+
# Extract the zip
79+
echo "Extracting $BINARY_NAME..."
80+
unzip -q "${BINARY_NAME}.zip"
81+
82+
# Move the binaries to /usr/local/bin
83+
echo "Installing $BINARY_NAME..."
84+
mv "${ASSET_NAME}/${BINARY_NAME}" /usr/local/bin/
85+
mv "${ASSET_NAME}/ya" /usr/local/bin/
86+
chmod +x /usr/local/bin/$BINARY_NAME
87+
chmod +x /usr/local/bin/ya
88+
89+
# Cleanup
90+
cd - || exit
91+
rm -rf "$TMP_DIR"
92+
93+
# Clean up
94+
rm -rf /var/lib/apt/lists/*
95+
96+
# Verify installation
97+
echo "Verifying installation..."
98+
$BINARY_NAME --version
99+
100+
echo "Done!"

test/_global/all-tools.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ check "codex" codex --version
1919
check "just" just --version
2020
check "opencode" opencode --version
2121
check "ccc" ccc --version
22+
check "yazi" yazi --version
2223

2324
reportResults

test/_global/scenarios.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"codex": {},
2121
"just": {},
2222
"opencode": {},
23-
"ccc": {}
23+
"ccc": {},
24+
"yazi": {}
2425
}
2526
},
2627
"flux-specific-version": {
@@ -156,5 +157,13 @@
156157
"version": "v0.1.5"
157158
}
158159
}
160+
},
161+
"yazi-specific-version": {
162+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
163+
"features": {
164+
"yazi": {
165+
"version": "v26.1.22"
166+
}
167+
}
159168
}
160169
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
set -e
4+
source dev-container-features-test-lib
5+
check "yazi with specific version" /bin/bash -c "yazi --version | grep '26.1.22'"
6+
7+
reportResults

test/yazi/test.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
source dev-container-features-test-lib
6+
check "yazi" yazi --version
7+
reportResults

0 commit comments

Comments
 (0)