In a recent project, I developed a script designed to expedite the markdown link creation process, specifically tailored for users of Safari, Apple’s native web browser. This script automates the generation of markdown links from selected text and the URL of the front-most active Safari tab. Inspired by John Lindquist, who created a similar tool for Google Chrome URLs, my goal was to bring this convenience to Safari users. By automating this task, the script aims to save time and enhance productivity for anyone working extensively with markdown, allowing for a smoother workflow and a focus on content rather than process.
#!/bin/bash
# Fetch the URL of the current tab in Safari using AppleScript
url=$(osascript -e 'tell application "Safari" to return URL of current tab of window 1')
# Format and echo the URL as a Markdown link
echo "[$1]($url)"
‘‘‘BSash url=$(osascript -e ‘tell application “Google Chrome” to return URL of active tab of front window’)
echo “$1” '’’