feat: Add support for directory templates

This commit is contained in:
2025-11-10 11:42:50 +01:00
parent e04f091704
commit f90adca156
2 changed files with 86 additions and 6 deletions

View File

@@ -49,6 +49,7 @@ end
function __env_complete_templates
set -l template_dir "$HOME/.config/fish/environments/templates"
if test -d "$template_dir"
# List file templates (*.fish)
for template_file in "$template_dir"/*.fish
if test -f "$template_file"
set template_name (basename "$template_file" .fish)
@@ -61,6 +62,29 @@ function __env_complete_templates
end
end
end
# List directory templates
for template_path in "$template_dir"/*
if test -d "$template_path"
set template_name (basename "$template_path")
set description "Multi-file template"
# Try to get description from readme.norg or activate.fish
if test -f "$template_path/readme.norg"
set first_line (head -n 1 "$template_path/readme.norg" | sed 's/^# *//')
if test -n "$first_line"
set description "$first_line"
end
else if test -f "$template_path/activate.fish"
set first_comment (head -n 5 "$template_path/activate.fish" | grep -E "^#[^!]" | head -n 1 | sed 's/^# *//')
if test -n "$first_comment"
set description "$first_comment"
end
end
echo -e "$template_name\t$description"
end
end
end
end