From ce910e4d52399357beb4996e5b64fe51822c79f5 Mon Sep 17 00:00:00 2001 From: Vijay A Date: Thu, 26 Dec 2024 19:32:07 +0530 Subject: [PATCH] Added script to export/import raycast configs --- CHANGELOG.md | 4 ++ Extras.md | 17 +++++++ scripts/capture-raycast-configs.sh | 78 ++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+) create mode 100755 scripts/capture-raycast-configs.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 659d161..433afe1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ As documented in the README's [adopting](README.md#how-to-adoptcustomize-the-scr For those who follow this repo, here's the changelog for ease of adoption: +### 1.0-45 + +* *[capture-raycast-configs.sh]* Added script to export/import raycast configs. More details can be found [here](Extras.md#capture-raycast-configssh). + ### 1.0-44 * *[recreate-repo.sh]* Fix an issue where a trailing slash would not properly process the repo in `${PERSONAL_PROFILES_DIR}` (ie would not force-squash) diff --git a/Extras.md b/Extras.md index 77a04a2..6f1c4fd 100644 --- a/Extras.md +++ b/Extras.md @@ -23,6 +23,23 @@ Note: This script is useful to capture the preferences of the known applications (both system-installed and custom-installed applications) using the `defaults read` command. It can be used to both export the preferences/settings (from the old system) or import them (into the new system) +## capture-raycast-configs.sh + +This script is useful to capture the raycast preferences/configurations. It can be used to both export the preferences/settings (from the old system) or import them (into the new system) + + ```bash + capture-raycast-configs.sh e "${PERSONAL_PROFILES_DIR}/extension-backups" + ``` + +*Please note:* + +Since this script uses applescript internally, it needs to be granted the following permissions: + +* `Privacy & Security > Accessibility` - need to enable/approve for iTerm and Terminal apps. +* `Privacy & Security > Automation` - need to enable/approve for "System Events" for iTerm and Terminal apps. +* Also, since this mimics keystrokes from the user, while this script is running, you should not move the mouse or type anything else using the keyboard or mouse. +* The above manual steps have to be performed after installing Raycast and running it at least once (so one has to click through the setup wizard). Due to this reason, this script has NOT been incorporated into the `fresh-install-of-osx.sh` script. + ## cleanup-browser-profiles.sh This script is used to cleanup browser profiles folders (delete cache, session and other files that will anyways be recreated when you restart that browser). It can be safely invoked even if that browser is running (in which case it will skip processing after printing a warning to quit that application) diff --git a/scripts/capture-raycast-configs.sh b/scripts/capture-raycast-configs.sh new file mode 100755 index 0000000..a40d506 --- /dev/null +++ b/scripts/capture-raycast-configs.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env zsh + +# vim:filetype=zsh syntax=zsh tabstop=2 shiftwidth=2 softtabstop=2 expandtab autoindent fileencoding=utf-8 + +# file location: + +# This script will export/import the raycast configs to/from the location specified in the target directory. +# Reference for keystrokes/keycodes: https://eastmanreference.com/complete-list-of-applescript-key-codes + +type warn &> /dev/null 2>&1 || source "${HOME}/.shellrc" + +set -euo pipefail + +usage() { + echo "$(red "Usage"): $(yellow "${1} ")" + echo " $(yellow 'e') --> Export from system" + echo " $(yellow 'i') --> Import into system" + echo " $(yellow 'target-dir-location') --> Directory name where the config has to be exported to/imported from" + exit 1 +} + +[ $# -ne 2 ] && usage "${0}" + +[[ "${1}" != 'e' && "${1}" != 'i' ]] && echo "$(red 'Unknown value entered') for first argument: '${1}'" && usage "${0}" + +local target_dir="${2}" +local target_file="${target_dir}/Raycast.rayconfig" +ensure_dir_exists "${target_dir}" + +if [[ "${1}" == 'e' ]]; then + rm -rfv "${target_dir}"/Raycast*.rayconfig + + open raycast://extensions/raycast/raycast/export-settings-data + + osascript <