From e89b14c699df81b2ed2eb5e3b909caca4438f25e Mon Sep 17 00:00:00 2001 From: Juan-Pablo Velez Date: Fri, 14 Nov 2025 20:49:35 -0500 Subject: [PATCH 1/2] Fix ohmyzsh plugins --- template/.devcontainer/devcontainer.json.jinja | 4 ++-- template/.devcontainer/installOhmyzshPlugins.sh | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 template/.devcontainer/installOhmyzshPlugins.sh diff --git a/template/.devcontainer/devcontainer.json.jinja b/template/.devcontainer/devcontainer.json.jinja index 5acb04e..ad6cfe3 100644 --- a/template/.devcontainer/devcontainer.json.jinja +++ b/template/.devcontainer/devcontainer.json.jinja @@ -3,7 +3,7 @@ "image": "mcr.microsoft.com/devcontainers/base:ubuntu-24.04", "features": { "ghcr.io/nils-geistmann/devcontainers-features/zsh:1": { - "plugins": "git colored-man-pages colorize history zsh-autosuggestions zsh-completions zsh-syntax-highlighting" + "plugins": "git colored-man-pages colorize history zsh-autosuggestions fast-syntax-highlighting zsh-autocomplete" }, "ghcr.io/guiyomh/features/just:0.1.0": { "version": "1.42.4" }{% if python %}, "ghcr.io/devcontainers/features/python:1": { @@ -39,7 +39,7 @@ "source=${localEnv:HOME}/.aws,target=/home/vscode/.aws,type=bind,consistency=cached" ], {% endif %} - "postCreateCommand": "bash ./.devcontainer/postCreateCommand.sh", + "postCreateCommand": "bash ./.devcontainer/postCreateCommand.sh && bash ./.devcontainer/installOhmyZshPlugins.sh", "customizations": { "vscode": { "extensions": [ diff --git a/template/.devcontainer/installOhmyzshPlugins.sh b/template/.devcontainer/installOhmyzshPlugins.sh new file mode 100644 index 0000000..c21a2a7 --- /dev/null +++ b/template/.devcontainer/installOhmyzshPlugins.sh @@ -0,0 +1,3 @@ +git clone https://github.com/zsh-users/zsh-autosuggestions.git ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions +git clone https://github.com/zdharma-continuum/fast-syntax-highlighting.git ~/.oh-my-zsh/custom/plugins/fast-syntax-highlighting +git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git ~/.oh-my-zsh/custom/plugins/zsh-autocomplete From de6ef193d271dfda1f95fe25649e69e56a4c45cb Mon Sep 17 00:00:00 2001 From: Juan-Pablo Velez Date: Sat, 15 Nov 2025 13:23:49 -0500 Subject: [PATCH 2/2] Add modern shell tools to devcontainer - Add modern-shell-tools devcontainer feature (eza, bat, ag, fd) - Create setupShellAliases.sh script to alias eza->ls, bat->cat, ag->grep - Call aliases script from postCreateCommand in devcontainer.json - Add test to verify modern shell tools configuration - fd is intentionally not aliased to allow explicit usage Closes #10 --- .../.devcontainer/devcontainer.json.jinja | 5 ++- template/.devcontainer/setupShellAliases.sh | 21 ++++++++++ tests/test_template.py | 38 ++++++++++++++++++- 3 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 template/.devcontainer/setupShellAliases.sh diff --git a/template/.devcontainer/devcontainer.json.jinja b/template/.devcontainer/devcontainer.json.jinja index ad6cfe3..93872b4 100644 --- a/template/.devcontainer/devcontainer.json.jinja +++ b/template/.devcontainer/devcontainer.json.jinja @@ -5,7 +5,8 @@ "ghcr.io/nils-geistmann/devcontainers-features/zsh:1": { "plugins": "git colored-man-pages colorize history zsh-autosuggestions fast-syntax-highlighting zsh-autocomplete" }, - "ghcr.io/guiyomh/features/just:0.1.0": { "version": "1.42.4" }{% if python %}, + "ghcr.io/guiyomh/features/just:0.1.0": { "version": "1.42.4" }, + "ghcr.io/meaningfy-ws/devcontainer-features/modern-shell-tools:1": {}{% if python %}, "ghcr.io/devcontainers/features/python:1": { "version": "os-provided", "installTools": "false" @@ -39,7 +40,7 @@ "source=${localEnv:HOME}/.aws,target=/home/vscode/.aws,type=bind,consistency=cached" ], {% endif %} - "postCreateCommand": "bash ./.devcontainer/postCreateCommand.sh && bash ./.devcontainer/installOhmyZshPlugins.sh", + "postCreateCommand": "bash ./.devcontainer/installOhmyZshPlugins.sh && bash ./.devcontainer/setupShellAliases.sh && bash ./.devcontainer/postCreateCommand.sh", "customizations": { "vscode": { "extensions": [ diff --git a/template/.devcontainer/setupShellAliases.sh b/template/.devcontainer/setupShellAliases.sh new file mode 100644 index 0000000..3606b13 --- /dev/null +++ b/template/.devcontainer/setupShellAliases.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# Set up shell aliases for modern tools +# These tools are installed via the modern-shell-tools devcontainer feature + +# Create or append to .zshrc +ZSHRC="$HOME/.zshrc" + +# Check if aliases already exist to avoid duplicates +if ! grep -q "# Modern shell tool aliases" "$ZSHRC" 2>/dev/null; then + cat >> "$ZSHRC" << 'EOF' + +# Modern shell tool aliases +alias ls='eza' +alias cat='bat' +alias grep='ag' +EOF + echo "Shell aliases configured successfully" +else + echo "Shell aliases already configured" +fi diff --git a/tests/test_template.py b/tests/test_template.py index 6c85dd3..a123db2 100644 --- a/tests/test_template.py +++ b/tests/test_template.py @@ -243,5 +243,41 @@ def test_devcontainer_zsh_feature(tmp_path: Path) -> None: assert_file_contains( dest, ".devcontainer/devcontainer.json", - "git colored-man-pages colorize history zsh-autosuggestions zsh-completions zsh-syntax-highlighting", + "git colored-man-pages colorize history zsh-autosuggestions fast-syntax-highlighting zsh-autocomplete", ) + + +def test_devcontainer_modern_shell_tools(tmp_path: Path) -> None: + """Test that modern shell tools are configured in devcontainer.""" + dest = tmp_path / "modern_shell" + res = run_copier( + Path(__file__).parents[1], + dest, + { + "author": "Test", + "email": "test@example.com", + "author_github_handle": "test", + "project_name": "modern-shell-proj", + "project_description": "Test modern shell tools", + "project_features": "[python_data_science]", + "use_github": True, + "open_source_license": "MIT license", + "aws": False, + }, + ) + assert res.returncode == 0, res.stderr + # Check that devcontainer includes the modern-shell-tools feature + assert_file_contains( + dest, ".devcontainer/devcontainer.json", '"ghcr.io/meaningfy-ws/devcontainer-features/modern-shell-tools:1"' + ) + # Check that postCreateCommand is configured to set up aliases + assert_file_contains(dest, ".devcontainer/devcontainer.json", "setupShellAliases.sh") + # Check that the aliases script exists + assert_exists(dest, ".devcontainer/setupShellAliases.sh") + # Check that the aliases script contains the expected aliases + assert_file_contains(dest, ".devcontainer/setupShellAliases.sh", "alias ls='eza'") + assert_file_contains(dest, ".devcontainer/setupShellAliases.sh", "alias cat='bat'") + assert_file_contains(dest, ".devcontainer/setupShellAliases.sh", "alias grep='ag'") + # Ensure fd is NOT aliased + content = (dest / ".devcontainer/setupShellAliases.sh").read_text() + assert "alias find=" not in content and "alias fd=" not in content, "fd should not be aliased"