Files
git.taskfile.build/bin/list-prompts
T
Janik von Rotz fa48eda0c0 feat(aliases): implement first-letter shorthand aliases for all bin scripts with collision handling
- Added alias functions to all bin scripts using first-letter pattern (e.g., `av` for `activate-venv`, `cwl` for `commit-with-llm`)
- Implemented collision resolution by extending aliases with additional letters when conflicts occur or when shadowing standard shell commands
- Documented alias implementation approach in library.md with complete alias map for reference
- Verified shell syntax with `bash -n` and ensured proper argument passing with `"$@"`
- Updated prompt frontmatter to reflect completed state and model used (infomaniak/moonshotai/Kimi-K2.6)
2026-07-08 15:42:22 +02:00

61 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
list-prompts() {
local prompts_dir="prompts"
if [ -n "$1" ]; then
prompts_dir="$1/prompts"
fi
if [[ ! -d "$prompts_dir" ]]; then
echo "No prompts directory found."
return 0
fi
local files=("$prompts_dir"/[0-9][0-9]_*.md)
if [[ ${#files[@]} -eq 0 ]]; then
echo "No prompt files found."
return 0
fi
local max_id_len=2
local max_title_len=10
local max_state_len=5
for file in "${files[@]}"; do
local id=${file#"$prompts_dir"/}
id=${id%%_*}
local title=$(grep -m1 '^title:' "$file" | sed 's/^title:[[:space:]]*//; s/^"\(.*\)"$/\1/')
local state=$(grep -m1 '^state:' "$file" | sed 's/^state:[[:space:]]*//; s/^"\(.*\)"$/\1/')
if [[ ${#id} -gt max_id_len ]]; then
max_id_len=${#id}
fi
if [[ ${#title} -gt max_title_len ]]; then
max_title_len=${#title}
fi
if [[ ${#state} -gt max_state_len ]]; then
max_state_len=${#state}
fi
done
printf "| %-${max_id_len}s | %-${max_title_len}s | %-${max_state_len}s |\n" "id" "title" "state"
printf "|-%s-|-%s-|-%s-|\n" "$(printf '%*s' "$max_id_len" '' | tr ' ' '-')" "$(printf '%*s' "$max_title_len" '' | tr ' ' '-')" "$(printf '%*s' "$max_state_len" '' | tr ' ' '-')"
for file in "${files[@]}"; do
local id=${file#"$prompts_dir"/}
id=${id%%_*}
local title=$(grep -m1 '^title:' "$file" | sed 's/^title:[[:space:]]*//; s/^"\(.*\)"$/\1/')
local state=$(grep -m1 '^state:' "$file" | sed 's/^state:[[:space:]]*//; s/^"\(.*\)"$/\1/')
printf "| %-${max_id_len}s | %-${max_title_len}s | %-${max_state_len}s |\n" "$id" "$title" "$state"
done
}
lp() {
list-prompts "$@"
}