Files
git.taskfile.build/bin/create-prompt
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

63 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
create-prompt() {
local title="$1"
if [[ -z "$title" ]]; then
echo "Error: Title cannot be empty."
echo "Usage: task create-prompt <title>"
return 1
fi
local prompts_dir="prompts"
if [ -n "$2" ]; then
prompts_dir="$2/prompts"
fi
if [[ ! -d "$prompts_dir" ]]; then
mkdir -p "$prompts_dir"
fi
local highest_num=0
for file in "$prompts_dir"/[0-9][0-9]_*.md; do
if [[ -f "$file" ]]; then
local num=${file#"$prompts_dir"/}
num=${num%%_*}
num=${num//[!0-9]/}
if [[ -n "$num" ]] && (( 10#$num > highest_num )); then
highest_num=$((10#$num))
fi
fi
done
local next_num=$((highest_num + 1))
local padded_num=$(printf "%02d" "$next_num")
local slug=$(echo "$title" | tr '[:upper:]' '[:lower:]'| tr '.' '-' | tr ' ' '-' | tr -cd '[:alnum:]-')
local filename="${padded_num}_${slug}.md"
local filepath="$prompts_dir/$filename"
if [[ -f "$filepath" ]]; then
echo "Error: File $filepath already exists."
return 1
fi
export PROMPT_TITLE="$title"
export PROMPT_ID="$padded_num"
envsubst < "$HOME/taskfile.build/prompt.md.template" > "$filepath"
if [[ -n "$EDITOR" ]]; then
"$EDITOR" "$filepath"
fi
echo 'File created:'
echo "$filepath"
# Copy path to clipboard
echo "$filepath" | copy-to-clipboard
echo "Path to prompt file copied to clipboard."
}
crp() {
create-prompt "$@"
}