Skip to content

Instantly share code, notes, and snippets.

@janzenz
Last active January 23, 2017 00:25
Show Gist options
  • Save janzenz/146f1ae3e3ec9bf9fe99146f6079deee to your computer and use it in GitHub Desktop.
Save janzenz/146f1ae3e3ec9bf9fe99146f6079deee to your computer and use it in GitHub Desktop.
This is my Solution for Pruning the TMUX Saved Sessions in tmux-resurrect

Make sure the shell is executable chown <userid>:<userid> tmux-resurrect-prune.sh chmod 4750 tmux-resurrect-prune.sh to make sure this is runnable and that you alone can run it under your user.

Load the .plist file, ironically you have to run this outside of tmux or you will get Operation not permitted error: http://superuser.com/questions/879640/error-while-trying-to-start-postgres-installed-via-homebrew-operation-not-permi/898585 launchtl load tmux-resurrect-prune.plist http://stackoverflow.com/questions/4485972/library-launchagents-plist-runs-manually-but-not-automatically I was looking for a way to do this run at machine wake: http://stackoverflow.com/questions/41688705/run-plist-on-wake

<?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>tmux-ressurect-prune</string>
<key>ProgramArguments</key>
<array>
<string>/Users/[userid]/bin/tmux-resurrect-prune.sh</string>
</array>
<key>KeepAlive</key>
<dict>
<key>PathState</key>
<dict>
<key>/Users/[userid]/bin/tmux-resurrect-prune.sh</key>
<true/>
</dict>
</dict>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
#!/usr/bin/env bash
cd $HOME/.tmux/resurrect && ls -A1t $HOME/.tmux/resurrect/ | tail -n +12 | xargs rm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment