Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
8 changes: 7 additions & 1 deletion src/modern-shell-utils/NOTES.md
Original file line number Diff line number Diff line change
@@ -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.
14 changes: 7 additions & 7 deletions src/modern-shell-utils/README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
5 changes: 2 additions & 3 deletions src/modern-shell-utils/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -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+"
}
86 changes: 27 additions & 59 deletions src/modern-shell-utils/install.sh
Original file line number Diff line number Diff line change
@@ -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!"
10 changes: 6 additions & 4 deletions test/modern-shell-utils/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading