33 lines
705 B
Bash
Executable File
33 lines
705 B
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> [repo-path]"
|
|
return 1
|
|
fi
|
|
|
|
local repo_path="${2:-.}"
|
|
local prompt_file="$repo_path/prompt.md"
|
|
|
|
local git_author
|
|
git_author="$(git log --format="%an <%ae>" -1 2>/dev/null || echo '')"
|
|
|
|
export PROMPT_TITLE="$title"
|
|
export PROMPT_AUTHOR="${git_author:-}"
|
|
|
|
envsubst < "$HOME/taskfile.build/prompt.md.template" > "$prompt_file"
|
|
|
|
if [[ -n "$EDITOR" ]]; then
|
|
"$EDITOR" "$prompt_file"
|
|
fi
|
|
|
|
echo "File created:"
|
|
echo "$prompt_file"
|
|
}
|
|
crp() {
|
|
create-prompt "$@"
|
|
}
|