Skip to content

Instantly share code, notes, and snippets.

@wifecooky
Created October 27, 2023 12:02
Show Gist options
  • Save wifecooky/399dd58809778286c857566d8c93b937 to your computer and use it in GitHub Desktop.
Save wifecooky/399dd58809778286c857566d8c93b937 to your computer and use it in GitHub Desktop.
convert-alfred-snippets-to-raycast-snippets
# Also posted here
# https://thewang.net/en/blog/Migrate-Alfred-Snippets-to-Raycast/
#!/bin/sh -e
# Script for converting Alfred snippets to Raycast snippets
# Usage: chmod +x convert.sh; ./convert.sh
# NOTE: Install jq before running this script
# List up all *.alfredsnippets files and rename them to *.zip
for file in *.alfredsnippets; do
mv "$file" "${file%.alfredsnippets}.zip"
done
# Unzip all *.zip files and get the folders name
for file in *.zip; do
unzip -o "$file" # -o: overwrite existing files without prompting
done
# Merge all *.json files to one file for Raycast snippets
jq -s 'map(.alfredsnippet | {name, keyword, text: .snippet})' *.json > ./output.json
# Clean up all files except output.json
for file in *.json; do
if [ "$file" = "output.json" ]; then
continue
fi
rm "$file"
done
for file in *.zip; do
rm "$file"
done
for file in *.plist; do
rm "$file"
done
# You can now import the output.json file to Raycast
echo "Done! 🎉 You can now import the output.json file to Raycast -> Import Snippets"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment