From 7442748e7968a7df143db9de3b29b7e2e920e0c2 Mon Sep 17 00:00:00 2001 From: mikaello <2505178+mikaello@users.noreply.github.com> Date: Wed, 23 Sep 2026 23:42:28 +0200 Subject: [PATCH 1/2] feat: replace ag with ripgrep and retain ag command --- .github/workflows/test.yaml | 4 +- README.md | 6 +- src/modern-shell-utils/NOTES.md | 8 +- src/modern-shell-utils/README.md | 14 +-- .../devcontainer-feature.json | 5 +- src/modern-shell-utils/install.sh | 86 ++++++------------- test/modern-shell-utils/test.sh | 10 ++- 7 files changed, 55 insertions(+), 78 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index f7cc974..ddd003b 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,8 +16,8 @@ jobs: - kotlinc - modern-shell-utils baseImage: - - debian:latest - - ubuntu:latest + - debian:13 + - ubuntu:24.04 - mcr.microsoft.com/devcontainers/base:ubuntu steps: - uses: actions/checkout@v7 diff --git a/README.md b/README.md index e6a88c5..708ca69 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,12 @@ Install the modern shell utilities: - [eza](https://eza.rocks/), _ls_ alternative (previously [exa](https://github.com/ogham/exa) was bundled) - [fd](https://github.com/sharkdp/fd), _find_ alternative -- [ag (The Silver Searcher)](https://github.com/ggreer/the_silver_searcher), - _grep_ alternative +- [ripgrep](https://github.com/BurntSushi/ripgrep), _grep_ alternative - [bat](https://github.com/sharkdp/bat), _cat_ alternative +`ag` remains available as a compatibility command for basic searches and runs `rg`. +Some `ag` options behave differently. + ### [`kotlinc`](src/kotlinc/README.md) Install _kotlinc_ and [_ktlint_](https://github.com/ktlint/ktlint). diff --git a/src/modern-shell-utils/NOTES.md b/src/modern-shell-utils/NOTES.md index ec1796c..00295d0 100644 --- a/src/modern-shell-utils/NOTES.md +++ b/src/modern-shell-utils/NOTES.md @@ -1,3 +1,9 @@ -# modern-shell-utils v2 +# modern-shell-utils v3 + +Replaced The Silver Searcher with the maintained `rg` from ripgrep. +An `ag` command points to `rg` for simple searches; some flags and output differ. +Requires Debian 13+ or Ubuntu 24.04+ with the distribution's `eza` package available. + +## Previous changes Replaced [`exa`](https://github.com/ogham/exa) with [`eza`](https://github.com/eza-community/eza) due to `exa` being deprecated. diff --git a/src/modern-shell-utils/README.md b/src/modern-shell-utils/README.md index 4da1f05..b981b96 100644 --- a/src/modern-shell-utils/README.md +++ b/src/modern-shell-utils/README.md @@ -1,23 +1,23 @@ # Modern shell utils (modern-shell-utils) -A collection of modern shell utils +eza, fd, ripgrep, and bat for Debian 13+ and Ubuntu 24.04+ ## Example Usage ```json "features": { - "ghcr.io/mikaello/devcontainer-features/modern-shell-utils:2": {} + "ghcr.io/mikaello/devcontainer-features/modern-shell-utils:3": {} } ``` -## Options +# modern-shell-utils v3 -| Options Id | Description | Type | Default Value | -|-----|-----|-----|-----| +Replaced The Silver Searcher with the maintained `rg` from ripgrep. +An `ag` command points to `rg` for simple searches; some flags and output differ. +Requires Debian 13+ or Ubuntu 24.04+ with the distribution's `eza` package available. - -# modern-shell-utils v2 +## Previous changes Replaced [`exa`](https://github.com/ogham/exa) with [`eza`](https://github.com/eza-community/eza) due to `exa` being deprecated. diff --git a/src/modern-shell-utils/devcontainer-feature.json b/src/modern-shell-utils/devcontainer-feature.json index b5f68fa..d3eda49 100644 --- a/src/modern-shell-utils/devcontainer-feature.json +++ b/src/modern-shell-utils/devcontainer-feature.json @@ -1,7 +1,6 @@ { "name": "Modern shell utils", "id": "modern-shell-utils", - "version": "2.0.0", - "description": "A collection of modern shell utils", - "options": {} + "version": "3.0.0", + "description": "eza, fd, ripgrep, and bat for Debian 13+ and Ubuntu 24.04+" } diff --git a/src/modern-shell-utils/install.sh b/src/modern-shell-utils/install.sh index 50a12bb..ffb0741 100644 --- a/src/modern-shell-utils/install.sh +++ b/src/modern-shell-utils/install.sh @@ -1,78 +1,46 @@ #!/usr/bin/env bash -set -e +set -euo pipefail echo "Activating feature 'modern-shell-utils'" -# Clean up -rm -rf /var/lib/apt/lists/* - -echo "Step 1, check if user is root" +echo "Step 1, check for root privileges" if [ "$(id -u)" -ne 0 ]; then - echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' + echo "This feature must be installed as root." >&2 exit 1 fi -echo "Step 2, determine appropriate non-root user" -if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then - USERNAME="" - POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)") - for CURRENT_USER in "${POSSIBLE_USERS[@]}"; do - if id -u "${CURRENT_USER}" >/dev/null 2>&1; then - USERNAME=${CURRENT_USER} - break - fi - done - if [ "${USERNAME}" = "" ]; then - USERNAME=root - fi -elif [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} >/dev/null 2>&1; then - USERNAME=root +echo "Step 2, check the distribution" +. /etc/os-release +if ! { [[ "${ID}" == "debian" ]] && dpkg --compare-versions "${VERSION_ID}" ge 13; } && + ! { [[ "${ID}" == "ubuntu" ]] && dpkg --compare-versions "${VERSION_ID}" ge 24.04; }; then + echo "Unsupported distribution: ${PRETTY_NAME}. This feature requires Debian 13+ or Ubuntu 24.04+." >&2 + exit 1 fi -echo "Step 3, define helper functions" -apt_get_update() -{ - if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then - echo "Running apt-get update..." - apt-get update -y - fi -} - -# Checks if packages are installed and installs them if not -check_packages() { - if ! dpkg -s "$@" > /dev/null 2>&1; then - apt_get_update - apt-get -y install --no-install-recommends "$@" - fi -} - export DEBIAN_FRONTEND=noninteractive +echo "Step 3, refresh package indexes" +rm -rf /var/lib/apt/lists/* +apt-get update -y -echo "Step 4, check if architecture is supported" -architecture="$(uname -m)" -if [ "${architecture}" != "amd64" ] && [ "${architecture}" != "x86_64" ] && [ "${architecture}" != "arm64" ] && [ "${architecture}" != "aarch64" ]; then - echo "(!) Architecture $architecture unsupported" +if ! apt-cache show eza >/dev/null 2>&1; then + echo "eza is unavailable from the configured APT sources. Enable the distribution's eza package repository." >&2 exit 1 fi +echo "Step 4, install eza, fd, ripgrep, and bat" +apt-get install -y --no-install-recommends eza fd-find ripgrep bat -echo "Step 4.5, add apt repo deb.gierens.de to get 'eza'. To be removed when 'eza' is available in mainstream repo" -check_packages ca-certificates gpg wget -mkdir -p /etc/apt/keyrings -wget -qO- https://raw.githubusercontent.com/eza-community/eza/main/deb.asc | gpg --dearmor -o /etc/apt/keyrings/gierens.gpg -echo "deb [signed-by=/etc/apt/keyrings/gierens.gpg] http://deb.gierens.de stable main" | tee /etc/apt/sources.list.d/gierens.list -chmod 644 /etc/apt/keyrings/gierens.gpg /etc/apt/sources.list.d/gierens.list -apt-get update -y - - -echo "Step 5, install packages" -check_packages eza fd-find silversearcher-ag bat - -ln -s /usr/bin/fdfind /usr/local/bin/fd -ln -s /usr/bin/batcat /usr/local/bin/bat - +echo "Step 5, expose fd, bat, and ag commands" +if ! command -v fd >/dev/null 2>&1; then + ln -sfn /usr/bin/fdfind /usr/local/bin/fd +fi +if ! command -v bat >/dev/null 2>&1; then + ln -sfn /usr/bin/batcat /usr/local/bin/bat +fi +if ! command -v ag >/dev/null 2>&1; then + ln -sfn /usr/bin/rg /usr/local/bin/ag +fi -# Clean up +echo "Step 6, clean up" rm -rf /var/lib/apt/lists/* - echo "Done!" diff --git a/test/modern-shell-utils/test.sh b/test/modern-shell-utils/test.sh index 4c1bed1..b0196d0 100644 --- a/test/modern-shell-utils/test.sh +++ b/test/modern-shell-utils/test.sh @@ -7,10 +7,12 @@ source dev-container-features-test-lib # Feature-specific tests # The 'check' command comes from the dev-container-features-test-lib. -check "version" ag --version -check "version" eza --version -check "version" fd --version -check "version" bat --version +check "eza" eza --version +check "fd" fd --version +check "ripgrep" rg --version +check "ag compatibility command" ag --version +check "ag simple search" bash -c 'printf "feature-check\n" | ag feature-check' +check "bat" bat --version # Report results # If any of the checks above exited with a non-zero exit code, the test will fail. From 60536f4e8a5ad343e3dfbac585c026641dfd6213 Mon Sep 17 00:00:00 2001 From: mikaello <2505178+mikaello@users.noreply.github.com> Date: Thu, 24 Sep 2026 15:29:24 +0200 Subject: [PATCH 2/2] test