Last active
December 21, 2023 02:53
-
-
Save timsu92/ff936c74cfab3bfda78b0d588089180d to your computer and use it in GitHub Desktop.
Cache cleaner
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
#!/usr/bin/env bash | |
echo "=============Poetry==============" | |
if command -v poetry > /dev/null; then | |
# 其他的可以看~/.cache/pypoetry/cache | |
poetry cache clear PyPI --all | |
poetry cache clear _default_cache --all | |
echo "Poetry's cache cleaned" | |
fi | |
echo "=============Python==============" | |
if command -v pip > /dev/null; then | |
pip cache purge | |
echo "pip's cache cleaned" | |
fi | |
if command -v pip3 > /dev/null; then | |
pip3 cache purge | |
echo "pip3's cache cleaned" | |
fi | |
echo "=============Node.js=============" | |
if command -v nvm > /dev/null; then | |
current_version=$(nvm current) | |
for version in $(nvm ls --no-colors | grep -o 'v[0-9]+\.[0-9]+\.[0-9]+' | uniq); do | |
if nvm use $version 2>/dev/null; then | |
# this node version exists | |
if command -v npm > /dev/null; then | |
npm cache clean --force | |
echo "npm's cache cleaned" | |
fi | |
if command -v pnpm > /dev/null; then | |
pnpm store prune | |
echo "pnpm's cache cleaned" | |
fi | |
if command -v yarn > /dev/null; then | |
yarn cache clean | |
echo "yarn's cache cleaned" | |
fi | |
fi | |
done | |
nvm use $current_version | |
else | |
if command -v npm > /dev/null; then | |
npm cache clean --force | |
echo "npm's cache cleaned" | |
fi | |
if command -v pnpm > /dev/null; then | |
pnpm store prune | |
echo "pnpm's cache cleaned" | |
fi | |
if command -v yarn > /dev/null; then | |
yarn cache clean | |
echo "yarn's cache cleaned" | |
fi | |
fi | |
echo "==============APT================" | |
sudo apt-get clean | |
echo "apt's cache cleaned" | |
echo "===========journalctl============" | |
# journalctl --disk-usage | |
sudo journalctl --vacuum-size=1 | |
echo "==============snap===============" | |
snap list --all | awk '/disabled/{print $1, $3}' | | |
while read snapname revision; do | |
sudo snap remove "$snapname" --revision="$revision" | |
done | |
echo "=============~/.cache============" | |
rm -r ~/.cache && echo "~/.cache removed" | |
echo "===============bun===============" | |
if command -v bun > /dev/null; then | |
rm -r ~/.bun/install/cache | |
echo "bun's cache cleaned" | |
fi | |
echo "==============Keras==============" | |
if [ -d ~/.keras ]; then | |
rm -r ~/.keras | |
echo "keras's cache cleaned" | |
fi | |
echo "=======Nvidia compute cache======" | |
if [ -d ~/.nv/ComputeCache ]; then | |
rm -r ~/.nv/ComputeCache | |
echo "Nvidia's cache cleaned" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment