Last active
June 3, 2024 19:16
-
-
Save gerardroche/6e46cbdf8da19a39f9da to your computer and use it in GitHub Desktop.
Clean Sublime Text caches and optionally clean out any sessions
This file contains hidden or 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
| #!/bin/sh | |
| set -e | |
| unset CDPATH | |
| unset IFS | |
| if [ "$1" = "-h" -o "$1" = "--help" ]; then | |
| echo "usage: [PROJECTS_PATH=<path>] $(basename $0) [--sessions] [--workspaces] | |
| Including the --sessions option will remove any sublime sessions. | |
| $ sublime-clean --sessions | |
| Including the --workspaces option and specifying a \"PROJECTS_PATH\" | |
| environment variable will remove any \"*.sublime-workspace\" files in the | |
| given projects path. The following will clear out sublime workspaces three | |
| levels deep within the ~/code directory. | |
| $ PROJECTS_PATH=~/code sublime-clean --workspaces | |
| " | |
| exit 0 | |
| fi | |
| # Clean ST2 | |
| # Always fully clean ST2 | |
| # I only use it for testing plugin compatability | |
| echo "=> clean ST2..." | |
| rm -rfv ~/.config/sublime-text-2/Installed\ Packages/ | |
| rm -rfv ~/.config/sublime-text-2/Packages/ | |
| rm -rfv ~/.config/sublime-text-2/Pristine\ Packages/ | |
| rm -fv ~/.config/sublime-text-2/Settings/*.sublime_session | |
| # Clean ST3 | |
| echo "=> clean ST3..." | |
| rm -rfv ~/.config/sublime-text-3/Cache/ | |
| rm -rfv ~/.config/sublime-text-3/Index/ | |
| if [ "$1" = "--sessions" ]; then | |
| echo "=> removing sessions..." | |
| shift | |
| rm -fv ~/.config/sublime-text-3/Local/*.sublime_session | |
| fi | |
| if [ "$1" = "--workspaces" ]; then | |
| echo "=> removing workspaces" | |
| shift | |
| rm -fv *.sublime-workspace | |
| if [ -d "$PROJECTS_PATH" ]; then | |
| rm -fv "$PROJECTS_PATH"/*.sublime-workspace | |
| rm -fv "$PROJECTS_PATH"/*/*.sublime-workspace | |
| rm -fv "$PROJECTS_PATH"/*/*/*.sublime-workspace | |
| rm -fv "$PROJECTS_PATH"/.sublime/*.sublime-workspace | |
| fi | |
| fi | |
| echo "=> done" |
OlivierBlanvillain
commented
Apr 20, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment