Skip to content

Instantly share code, notes, and snippets.

@burke
Created January 31, 2022 17:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save burke/a1b36f5dd78d6a5922f6c50cdf299b93 to your computer and use it in GitHub Desktop.
Save burke/a1b36f5dd78d6a5922f6c50cdf299b93 to your computer and use it in GitHub Desktop.
#!/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