Skip to content

Commit

Permalink
feat: set default title and update title argument optional
Browse files Browse the repository at this point in the history
  • Loading branch information
atzzCokeK committed Oct 14, 2023
1 parent 61c7964 commit 2fc559b
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions commands/conversions/inputs-to-markdown-link.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,26 @@

# Optional parameters:
# @raycast.icon 🔗
# @raycast.argument1 { "type": "text", "placeholder": "Title" }
# @raycast.argument2 { "type": "text", "placeholder": "URL" }
# @raycast.argument1 { "type": "text", "placeholder": "URL" }
# @raycast.argument2 { "type": "text", "placeholder": "Title (default: Link)", "optional": true }

# Description:
# Quickly and simply generate a markdown formatted link with your specified title and URL.
# Quickly and simply generate a markdown formatted link with your specified URL and title.
# The generated link is copied to your clipboard for easy pasting.

# Documentation:
# @raycast.author atzzCokeK
# @raycast.authorURL https://github.com/atzzCokeK

URL=$1
TITLE=${2:-Link} # Use "Link" as default if title is not provided

regex='(https?|ftp|file)://[-[:alnum:]\+&@#/%?=~_|!:,.;]+'

if [[ $2 =~ $regex ]]; then
echo "[$1]($2)" | pbcopy
echo "Copied: [$1]($2)"
if [[ $URL =~ $regex ]]; then
echo "[$TITLE]($URL)" | pbcopy
echo "Copied: [$TITLE]($URL)"
else
echo "Invalid URL: $2"
echo "Invalid URL: $URL"
exit 1
fi

0 comments on commit 2fc559b

Please sign in to comment.