Skip to content

Commit 5c4c3bf

Browse files
committed
feat(.functions): prompts
1 parent 27f0ea6 commit 5c4c3bf

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

dotfiles/.functions.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,3 +595,29 @@ jgl() {
595595
jj git fetch
596596
jj new "$b"
597597
}
598+
599+
#----------------
600+
601+
# cat and copy to clipboard a prompt file under the prompts directory.
602+
# If an argument is given, it is used as a prefix to find the prompt file.
603+
# If no argument is given, lists available prompt files without extensions.
604+
prompt() {
605+
local dir="$HOME/Desktop/interface/doc/prompts"
606+
if [[ -n "$1" ]]; then
607+
local file
608+
file=$(find "$dir" -maxdepth 1 -type f -name "$1*" | head -1)
609+
610+
if [[ -n "$file" ]]; then
611+
command cat "$file"
612+
pbc < <(cat "$file")
613+
else
614+
while IFS= read -r f; do
615+
basename "$f" | sed 's/\.[^.]*$//'
616+
done < <(find "$dir" -maxdepth 1 -type f)
617+
fi
618+
else
619+
while IFS= read -r f; do
620+
basename "$f" | sed 's/\.[^.]*$//'
621+
done < <(find "$dir" -maxdepth 1 -type f)
622+
fi
623+
}

0 commit comments

Comments
 (0)