Skip to content

Instantly share code, notes, and snippets.

@yugoslavskiy
Forked from gerardroche/sublime-clean
Last active April 26, 2016 01:19
Show Gist options
  • Save yugoslavskiy/8c51a6af08b58f42dccc to your computer and use it in GitHub Desktop.
Save yugoslavskiy/8c51a6af08b58f42dccc to your computer and use it in GitHub Desktop.

Revisions

  1. yugoslavskiy revised this gist Apr 26, 2016. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions sublime_clean
    Original file line number Diff line number Diff line change
    @@ -23,5 +23,8 @@ rm -fv "${ST3_PATH}"/Local/*.sublime_session
    echo "[*] remove workspaces..."
    sudo find / -type f -name '*.sublime-workspace' -exec rm -fv {} + 2>/dev/null

    echo ""
    echo "[*] sublime-clean: Done."
    echo ""

    exit 0
  2. yugoslavskiy revised this gist Mar 21, 2016. No changes.
  3. yugoslavskiy renamed this gist Mar 20, 2016. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. yugoslavskiy revised this gist Mar 20, 2016. No changes.
  5. yugoslavskiy revised this gist Mar 20, 2016. 1 changed file with 0 additions and 5 deletions.
    5 changes: 0 additions & 5 deletions sublime-clean
    Original file line number Diff line number Diff line change
    @@ -7,26 +7,21 @@ set -e
    unset CDPATH
    unset IFS


    [ $( uname -s ) = "Darwin" ] && ST3_PATH=~/Library/Application\ Support/Sublime\ Text\ 3
    [ $( uname -s ) = "Linux" ] && ST3_PATH=~/.config/sublime-text-3

    echo "[*] remove cache..."

    rm -rfv "${ST3_PATH}"/Packages/.logs/
    rm -rfv "${ST3_PATH}"/Backup/
    rm -rfv "${ST3_PATH}"/Cache/
    rm -rfv "${ST3_PATH}"/Index/
    rm -rfv "${ST3_PATH}"/Settings/

    echo "[*] remove sesions..."

    rm -fv "${ST3_PATH}"/Local/*.sublime_session

    echo "[*] remove workspaces..."

    sudo find / -type f -name '*.sublime-workspace' -exec rm -fv {} + 2>/dev/null

    echo "[*] sublime-clean: Done."

    exit 0
  6. yugoslavskiy revised this gist Mar 20, 2016. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions sublime-clean
    Original file line number Diff line number Diff line change
    @@ -13,15 +13,15 @@ unset IFS

    echo "[*] remove cache..."

    rm -rfv ${ST3_PATH}/Packages/.logs/
    rm -rfv ${ST3_PATH}/Backup/
    rm -rfv ${ST3_PATH}/Cache/
    rm -rfv ${ST3_PATH}/Index/
    rm -rfv ${ST3_PATH}/Settings/
    rm -rfv "${ST3_PATH}"/Packages/.logs/
    rm -rfv "${ST3_PATH}"/Backup/
    rm -rfv "${ST3_PATH}"/Cache/
    rm -rfv "${ST3_PATH}"/Index/
    rm -rfv "${ST3_PATH}"/Settings/

    echo "[*] remove sesions..."

    rm -fv ${ST3_PATH}/Local/*.sublime_session
    rm -fv "${ST3_PATH}"/Local/*.sublime_session

    echo "[*] remove workspaces..."

  7. yugoslavskiy revised this gist Mar 20, 2016. 1 changed file with 17 additions and 81 deletions.
    98 changes: 17 additions & 81 deletions sublime-clean
    Original file line number Diff line number Diff line change
    @@ -1,96 +1,32 @@
    #!/bin/sh

    # original file:
    # https://gist.github.com/gerardroche/6e46cbdf8da19a39f9da

    set -e
    unset CDPATH
    unset IFS

    show_usage() {
    echo "usage: [PROJECTS_PATH=<path>] $(basename $0) [--sessions] [--workspaces]
    By default sessions and workspaces are not removed.
    The PROJECTS_PATH environment variable can be used to specify a location to
    find sublime workspaces.
    ## Example
    The following will remove all sublime workspaces, \"*.sublime-workspace\",
    within the ~/code directory.
    $ PROJECTS_PATH=~/code sublime-clean --workspaces
    "

    }

    while test "$#" != 0; do
    case "$1" in
    --help|-h) show_usage; exit 0 ;;
    --sessions) REMOVE_SESSIONS=y ;;
    --workspaces) REMOVE_WORKSPACES=y ;;
    --) shift; break ;; # standard terminate loop; end of options list
    -*) echo >&2 "$0: unknown option '$1'"; exit 1 ;;
    *) echo >&2 "$0: unknown argument '$1'"; exit 1 ;;
    esac
    shift
    done

    echo "=> ST2..."

    # ST2 Linux
    rm -rfv ~/.config/sublime-text-2/Installed\ Packages/
    rm -rfv ~/.config/sublime-text-2/Packages/
    rm -rfv ~/.config/sublime-text-2/Pristine\ Packages/

    # ST2 OSX
    rm -rfv ~/Library/Application\ Support/Sublime\ Text\ 2/Installed\ Packages/
    rm -rfv ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/
    rm -rfv ~/Library/Application\ Support/Sublime\ Text\ 2/Pristine\ Packages/

    if [ "$REMOVE_SESSIONS" = "y" ]; then

    # ST2 Linux sessions
    rm -fv ~/.config/sublime-text-2/Settings/*.sublime_session

    # ST2 OSX sessions
    rm -fv ~/Library/Application\ Support/Sublime\ Text\ 2/Settings/*.sublime_session

    fi

    echo "=> ST3..."
    [ $( uname -s ) = "Darwin" ] && ST3_PATH=~/Library/Application\ Support/Sublime\ Text\ 3
    [ $( uname -s ) = "Linux" ] && ST3_PATH=~/.config/sublime-text-3

    # ST3 Linux
    rm -rfv ~/.config/sublime-text-3/Packages/.logs/
    rm -rfv ~/.config/sublime-text-3/Backup/
    rm -rfv ~/.config/sublime-text-3/Cache/
    rm -rfv ~/.config/sublime-text-3/Index/
    rm -rfv ~/.config/sublime-text-3/Settings/
    echo "[*] remove cache..."

    # ST3 OSX
    rm -rfv ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/.logs/
    rm -rfv ~/Library/Application\ Support/Sublime\ Text\ 3/Backup/
    rm -rfv ~/Library/Application\ Support/Sublime\ Text\ 3/Cache/
    rm -rfv ~/Library/Application\ Support/Sublime\ Text\ 3/Index/
    rm -rfv ~/Library/Application\ Support/Sublime\ Text\ 3/Settings/
    rm -rfv ${ST3_PATH}/Packages/.logs/
    rm -rfv ${ST3_PATH}/Backup/
    rm -rfv ${ST3_PATH}/Cache/
    rm -rfv ${ST3_PATH}/Index/
    rm -rfv ${ST3_PATH}/Settings/

    if [ "$REMOVE_SESSIONS" = "y" ]; then
    echo "[*] remove sesions..."

    # ST3 Linux sessions
    rm -fv ~/.config/sublime-text-3/Local/*.sublime_session
    rm -fv ${ST3_PATH}/Local/*.sublime_session

    # ST3 OSX sessions
    rm -fv ~/Library/Application\ Support/Sublime\ Text\ 3/Local/*.sublime_session
    echo "[*] remove workspaces..."

    fi
    sudo find / -type f -name '*.sublime-workspace' -exec rm -fv {} + 2>/dev/null

    if [ "$REMOVE_WORKSPACES" = "y" ]; then
    echo "=> remove workspaces..."
    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 "[*] sublime-clean: Done."

    echo "=> done"
    exit 0
  8. @gerardroche gerardroche revised this gist Feb 3, 2016. 1 changed file with 27 additions and 5 deletions.
    32 changes: 27 additions & 5 deletions sublime-clean
    Original file line number Diff line number Diff line change
    @@ -34,30 +34,52 @@ while test "$#" != 0; do
    shift
    done

    # ST2

    echo "=> ST2..."

    # ST2 Linux
    rm -rfv ~/.config/sublime-text-2/Installed\ Packages/
    rm -rfv ~/.config/sublime-text-2/Packages/
    rm -rfv ~/.config/sublime-text-2/Pristine\ Packages/

    # ST2 OSX
    rm -rfv ~/Library/Application\ Support/Sublime\ Text\ 2/Installed\ Packages/
    rm -rfv ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/
    rm -rfv ~/Library/Application\ Support/Sublime\ Text\ 2/Pristine\ Packages/

    if [ "$REMOVE_SESSIONS" = "y" ]; then

    # ST2 Linux sessions
    rm -fv ~/.config/sublime-text-2/Settings/*.sublime_session
    fi

    # ST3
    # ST2 OSX sessions
    rm -fv ~/Library/Application\ Support/Sublime\ Text\ 2/Settings/*.sublime_session

    fi

    echo "=> ST3..."

    # ST3 Linux
    rm -rfv ~/.config/sublime-text-3/Packages/.logs/
    rm -rfv ~/.config/sublime-text-3/Backup/
    rm -rfv ~/.config/sublime-text-3/Cache/
    rm -rfv ~/.config/sublime-text-3/Index/
    rm -rfv ~/.config/sublime-text-3/Settings/

    # ST3 OSX
    rm -rfv ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/.logs/
    rm -rfv ~/Library/Application\ Support/Sublime\ Text\ 3/Backup/
    rm -rfv ~/Library/Application\ Support/Sublime\ Text\ 3/Cache/
    rm -rfv ~/Library/Application\ Support/Sublime\ Text\ 3/Index/
    rm -rfv ~/Library/Application\ Support/Sublime\ Text\ 3/Settings/

    if [ "$REMOVE_SESSIONS" = "y" ]; then

    # ST3 Linux sessions
    rm -fv ~/.config/sublime-text-3/Local/*.sublime_session

    # ST3 OSX sessions
    rm -fv ~/Library/Application\ Support/Sublime\ Text\ 3/Local/*.sublime_session

    fi

    if [ "$REMOVE_WORKSPACES" = "y" ]; then
    @@ -71,4 +93,4 @@ if [ "$REMOVE_WORKSPACES" = "y" ]; then
    fi
    fi

    echo "=> done"
    echo "=> done"
  9. @gerardroche gerardroche revised this gist Feb 3, 2016. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion sublime-clean
    Original file line number Diff line number Diff line change
    @@ -50,8 +50,11 @@ fi

    echo "=> ST3..."

    rm -rfv ~/.config/sublime-text-3/Packages/.logs/
    rm -rfv ~/.config/sublime-text-3/Backup/
    rm -rfv ~/.config/sublime-text-3/Cache/
    rm -rfv ~/.config/sublime-text-3/Index/
    rm -rfv ~/.config/sublime-text-3/Settings/

    if [ "$REMOVE_SESSIONS" = "y" ]; then
    rm -fv ~/.config/sublime-text-3/Local/*.sublime_session
    @@ -68,4 +71,4 @@ if [ "$REMOVE_WORKSPACES" = "y" ]; then
    fi
    fi

    echo "=> done"
    echo "=> done"
  10. @gerardroche gerardroche revised this gist Jan 9, 2016. 1 changed file with 38 additions and 24 deletions.
    62 changes: 38 additions & 24 deletions sublime-clean
    Original file line number Diff line number Diff line change
    @@ -4,47 +4,61 @@ set -e
    unset CDPATH
    unset IFS

    if [ "$1" = "-h" -o "$1" = "--help" ]; then
    show_usage() {
    echo "usage: [PROJECTS_PATH=<path>] $(basename $0) [--sessions] [--workspaces]
    Including the --sessions option will remove any sublime sessions.
    By default sessions and workspaces are not removed.
    $ sublime-clean --sessions
    The PROJECTS_PATH environment variable can be used to specify a location to
    find sublime workspaces.
    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.
    ## Example
    $ PROJECTS_PATH=~/code sublime-clean --workspaces
    "
    exit 0
    fi
    The following will remove all sublime workspaces, \"*.sublime-workspace\",
    within the ~/code directory.
    $ PROJECTS_PATH=~/code sublime-clean --workspaces
    "

    }

    while test "$#" != 0; do
    case "$1" in
    --help|-h) show_usage; exit 0 ;;
    --sessions) REMOVE_SESSIONS=y ;;
    --workspaces) REMOVE_WORKSPACES=y ;;
    --) shift; break ;; # standard terminate loop; end of options list
    -*) echo >&2 "$0: unknown option '$1'"; exit 1 ;;
    *) echo >&2 "$0: unknown argument '$1'"; exit 1 ;;
    esac
    shift
    done

    # ST2

    echo "=> ST2..."

    # 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..."
    if [ "$REMOVE_SESSIONS" = "y" ]; then
    rm -fv ~/.config/sublime-text-2/Settings/*.sublime_session
    fi

    # ST3

    echo "=> ST3..."

    rm -rfv ~/.config/sublime-text-3/Cache/
    rm -rfv ~/.config/sublime-text-3/Index/

    if [ "$1" = "--sessions" ]; then
    echo "=> removing sessions..."
    shift
    if [ "$REMOVE_SESSIONS" = "y" ]; then
    rm -fv ~/.config/sublime-text-3/Local/*.sublime_session
    fi

    if [ "$1" = "--workspaces" ]; then
    echo "=> removing workspaces"
    shift
    if [ "$REMOVE_WORKSPACES" = "y" ]; then
    echo "=> remove workspaces..."
    rm -fv *.sublime-workspace
    if [ -d "$PROJECTS_PATH" ]; then
    rm -fv "$PROJECTS_PATH"/*.sublime-workspace
  11. @gerardroche gerardroche revised this gist Nov 14, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion sublime-clean
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ if [ "$1" = "-h" -o "$1" = "--help" ]; then
    $ sublime-clean --sessions
    Including the --workspaces option and specifying a \"PROJECTS_PATH\"
    environment variable will remove any \"*.sublime-workspace\" files with the
    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.
  12. @gerardroche gerardroche revised this gist Nov 14, 2015. 1 changed file with 17 additions and 10 deletions.
    27 changes: 17 additions & 10 deletions sublime-clean
    Original file line number Diff line number Diff line change
    @@ -1,19 +1,26 @@
    #!/bin/sh
    #
    # To remove "*.sublime-workspace" files specify a location via a
    # `PROJECTS_PATH` environment variable and add the `--workspaces` option.
    #
    # ```sh
    # $ PROJECTS_PATH=~/code sublime-clean --workspaces
    # ```
    #
    # The above will clear out workspaces three levels deep within the `~/code`
    # directory.

    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 with 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
  13. @gerardroche gerardroche revised this gist Nov 14, 2015. 1 changed file with 5 additions and 2 deletions.
    7 changes: 5 additions & 2 deletions sublime-clean
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,14 @@
    #!/bin/sh
    #
    # To clear out "*,sublime-workspace" files specify a location via a `PROJECTS_PATH` environment variable.
    # To remove "*.sublime-workspace" files specify a location via a
    # `PROJECTS_PATH` environment variable and add the `--workspaces` option.
    #
    # ```sh
    # $ PROJECTS_PATH=~/code sublime-clean --workspaces
    # ```
    # The above will clear out workspaces three levels deep within the `PROJECT_PATH` location.
    #
    # The above will clear out workspaces three levels deep within the `~/code`
    # directory.

    set -e
    unset CDPATH
  14. @gerardroche gerardroche revised this gist Nov 14, 2015. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions sublime-clean
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,11 @@
    #!/bin/sh
    #
    # To clear out "*,sublime-workspace" files specify a location via a `PROJECTS_PATH` environment variable.
    #
    # ```sh
    # $ PROJECTS_PATH=~/code sublime-clean --workspaces
    # ```
    # The above will clear out workspaces three levels deep within the `PROJECT_PATH` location.

    set -e
    unset CDPATH
  15. @gerardroche gerardroche revised this gist Nov 14, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions sublime-clean
    Original file line number Diff line number Diff line change
    @@ -16,8 +16,8 @@ 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/
    rm -rfv ~/.config/sublime-text-3/Cache/
    rm -rfv ~/.config/sublime-text-3/Index/

    if [ "$1" = "--sessions" ]; then
    echo "=> removing sessions..."
  16. @gerardroche gerardroche revised this gist Nov 11, 2015. 1 changed file with 25 additions and 7 deletions.
    32 changes: 25 additions & 7 deletions sublime-clean
    Original file line number Diff line number Diff line change
    @@ -1,22 +1,40 @@
    #!/bin/sh
    #
    # Sublime Text cache, index, session, etc. cleaner

    set -e
    unset CDPATH
    unset IFS

    # Always fully clean ST2, because I only use it for testing plugin compatability.
    # 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

    # ST3
    # Clean ST3
    echo "=> clean ST3..."

    rm -rfv ~/.config/sublime-text-3/Cache/
    rm -rfv ~/.config/sublime-text-3/Index/
    # rm -rfv ~/.config/sublime-text-3/Cache/
    # rm -rfv ~/.config/sublime-text-3/Index/

    if [ "$1" = "--include-sessions" ]; then
    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"
  17. @gerardroche gerardroche revised this gist Jun 14, 2015. 1 changed file with 10 additions and 1 deletion.
    11 changes: 10 additions & 1 deletion sublime-clean
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,22 @@
    #!/bin/sh
    #
    # Sublime Text cache, index, session, etc. cleaner

    set -e
    unset CDPATH
    unset IFS

    # Always fully clean ST2, because I only use it for testing plugin compatability.
    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

    # ST3

    rm -rfv ~/.config/sublime-text-3/Cache/
    rm -rfv ~/.config/sublime-text-3/Index/

    if [ "$1" = "--include-sessions" ]; then
    rm -fv ~/.config/sublime-text-3/Local/*.sublime_session
    rm -fv ~/.config/sublime-text-2/Settings/*.sublime_session
    fi
  18. @gerardroche gerardroche created this gist Jan 19, 2015.
    13 changes: 13 additions & 0 deletions sublime-clean
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    #!/bin/sh

    set -e
    unset CDPATH
    unset IFS

    rm -rfv ~/.config/sublime-text-3/Cache/
    rm -rfv ~/.config/sublime-text-3/Index/

    if [ "$1" = "--include-sessions" ]; then
    rm -fv ~/.config/sublime-text-3/Local/*.sublime_session
    rm -fv ~/.config/sublime-text-2/Settings/*.sublime_session
    fi