Skip to content

Instantly share code, notes, and snippets.

@burke
Created Jan 31, 2022
Embed
What would you like to do?
#!/bin/bash
set -euo pipefail
plists=()
while read -r pl; do
plists+=("${pl}")
done < <(ls ~/Library/LaunchAgents)
len=${#plists[@]}
height=$((len + 2))
fzf_args=(--height "${height}" --reverse --select-1 --prompt "Select a LaunchAgent to reload: ")
if [[ -n "${1:-}" ]]; then
fzf_args+=(--query "$1")
fi
plist=$( (IFS=$'\n'; echo "${plists[*]}") | fzf "${fzf_args[@]}")
pth="${HOME}/Library/LaunchAgents/${plist}"
launchctl unload -w "${pth}" || true
launchctl load -w "${pth}"
echo "Reloaded ${plist}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment