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
7 changes: 4 additions & 3 deletions template/.devcontainer/devcontainer.json.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"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/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"
Expand Down Expand Up @@ -39,7 +40,7 @@
"source=${localEnv:HOME}/.aws,target=/home/vscode/.aws,type=bind,consistency=cached"
],
{% endif %}
"postCreateCommand": "bash ./.devcontainer/postCreateCommand.sh",
"postCreateCommand": "bash ./.devcontainer/installOhmyZshPlugins.sh && bash ./.devcontainer/setupShellAliases.sh && bash ./.devcontainer/postCreateCommand.sh",
"customizations": {
"vscode": {
"extensions": [
Expand Down
3 changes: 3 additions & 0 deletions template/.devcontainer/installOhmyzshPlugins.sh
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions template/.devcontainer/setupShellAliases.sh
Original file line number Diff line number Diff line change
@@ -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
38 changes: 37 additions & 1 deletion tests/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"