Skip to content

Instantly share code, notes, and snippets.

@3v1n0
Last active April 19, 2024 14:51
Show Gist options
  • Star 28 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save 3v1n0/8e27c06ca88159fdc140533608edbe37 to your computer and use it in GitHub Desktop.
Save 3v1n0/8e27c06ca88159fdc140533608edbe37 to your computer and use it in GitHub Desktop.
VSCode unused workspaceStorage cleanup
#!/bin/bash
CONFIG_PATH=~/.config/Code
for i in $CONFIG_PATH/User/workspaceStorage/*; do
if [ -f $i/workspace.json ]; then
folder="$(python3 -c "import sys, json; print(json.load(open(sys.argv[1], 'r'))['folder'])" $i/workspace.json 2>/dev/null | sed 's#^file://##;s/+/ /g;s/%\(..\)/\\x\1/g;')"
if [ -n "$folder" ] && [ ! -d "$folder" ]; then
echo "Removing workspace $(basename $i) for deleted folder $folder of size $(du -sh $i|cut -f1)"
rm -rfv "$i"
fi
fi
done
@vaivaswatha
Copy link

Thank you! I was looking for exactly this, everywhere, until I found happened to find this script. This functionality should've been part of VSCode.

@AlyIbrahim
Copy link

This script did the job for me !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment