Last active
January 16, 2024 20:10
-
-
Save mrdomino/e988ab72cb46571dc5f5a9accadb53d9 to your computer and use it in GitHub Desktop.
kill zsh with USR1 every time a path directory changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>org.wholezero.watchpath</string> | |
<key>ProgramArguments</key> | |
<array> | |
<string>/bin/zsh</string> | |
<string>-lc</string> | |
<string>fswatch -o "${path[@]}" | xargs -n1 -I{} pkill -USR1 -u "$UID" zsh</string> | |
</array> | |
<key>KeepAlive</key> | |
<true/> | |
</dict> | |
</plist> | |
<!-- vi: set noet :vi --> |
Oh, I had a hard time getting this working. This is what worked for me in the end:
launchctl enable gui/$(id -u)/org.wholezero.watchpath
launchctl load -w ~/Library/LaunchAgents/org.wholezero.watchpath.plist
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For this to work, you need something like this in your
~/.zshrc
:TRAPUSR1() { rehash }
And you probably want something like this in
~/.zshenv
: