本文共 6603 字,大约阅读时间需要 22 分钟。
mac 释放空间
I love cleaning software? PLZ! Remove duplicates, find old OS cruft etc. But it never cleans a development machine as I can.
一世 喜欢清洁软件? PLZ! 删除重复项,找到旧的OS崩溃等。但是它从来没有尽我所能清理开发机器。
Sure, for general maintenance, nothing beats . But once a year, developers should run through a few manual commands, because auto-cleaners won’t know how to take care of a developer machine.
当然,对于常规维护, 没有什么比这 。 但是,每年一次,开发人员应该执行一些手动命令,因为自动清洁器不知道如何保养开发人员的机器。
Before we start, let’s look at how much “Free Space” you’re starting with:
在开始之前,让我们先看看您有多少“可用空间”:
Mine is reporting 132.2 GB before cleaning. Time to get started!
矿山报告在清洁前为132.2 GB。 是时候开始了!
This one usually shaves off hundreds of megs of data. Update, upgrade, and then clean up those files you’re not going to use.
通常,这可以节省数百兆的数据。 更新,升级然后清理您将不使用的文件。
Update then remove old formulae and their folders:
更新然后删除旧公式及其文件夹:
brew update && brew upgrade && brew cleanup
You might have used brew prune
in the past, but that has been deprecated. Cleanup handles this for you!
您过去可能曾经使用过brew prune
,但是已经过时了。 清理为您处理!
Brew is a complicated system, and no one knows it better than the maintainers. So you can run brew doctor
and get some additional chores you could take care of to have it run properly.
Brew是一个复杂的系统,没有人比维护人员更了解它。 因此,您可以运行brew doctor
并获得一些其他杂务,以使其正常运行。
Git is great, but it’s not hard to leave a bunch of merged branches laying around on your local machine! Those branches aren’t useful anymore, and sometimes make naming conflicts for future branches.
Git很棒,但是在本地计算机上留下一堆合并的分支并不难! 这些分支不再有用,有时会为将来的分支命名冲突。
You can remove all the merged branches from a single project with this command:
您可以使用以下命令从单个项目中删除所有合并的分支:
git branch --merged master | grep -v "\* master" | xargs -n 1 git branch -d
WOW, what a mouthful for only one project! Let’s make it worse. ?
哇,只有一个项目真是令人a目结舌! 让我们变得更糟。 ?
This code will CD into all folders in the current working directory, and then run the command to clean merged branches for each!
此代码将CD放入当前工作目录中的所有文件夹,然后运行命令为每个清理合并的分支!
for d in */; do cd $d; echo WORKING ON $d; git branch --merged master | grep -v "\* master" | xargs -n 1 git branch -d; cd ..; done
The following command finds all node_modules
folders older than 120 days and removes them. This does mean you will have to npm i
or yarn
again in those older projects. This is usually a huge cleanup!
以下命令查找所有早于120天的node_modules
文件夹并将其删除。 这的确意味着您将不得不在这些较早的项目中再次npm i
或yarn
。 通常这是一个巨大的清理工作!
Removes all node_modules
folders older than 4 months:
删除所有4个月以上的node_modules
文件夹:
find . -name "node_modules" -type d -mtime +120 | xargs rm -rf
If you’re feeling quite aggressive, you can just clear out ALL node_modules
folders and re-install as needed, by removing the mtime
flag.
如果您感觉非常激进,则可以清除所有node_modules
文件夹,然后根据需要通过删除mtime
标志来重新安装。
Removes all node_modules
folders:
删除所有的node_modules
文件夹:
find . -name "node_modules" -type d | xargs rm -rf
Remove old versions of Node. This varies depending on your Node manager. I use ’n’ so it’s easy for me. Consult uninstall for your specific version manager.
删除旧版本的Node。 这取决于您的节点管理器。 我使用“ n”,所以对我来说很容易。 请咨询您的特定版本管理器的卸载。
Using
n
?使用
n
?
List all versions of node + your installed ones with
n ls
and then remove any withn rm <versi
on>.用
n ls
列出节点+已安装的所有版本,然后用n rm <versi
on>删除所有版本。
Using
nvm
?使用
nvm
吗?
List your installed versions with
nvm ls
and then remove any withnvm uninstall <versi
on>.使用
nvm ls
列出安装的版本,然后使用nvm uninstall <versi
on>删除所有版本。
Using
asdf
?使用
asdf
吗?
List your installed versions with
asdf list nodejs
and then remove any withasdf uninstall nodejs <versi
on>.使用
asdf list nodejs
列出您的已安装版本,然后使用asdf uninstall nodejs <versi
on>删除所有版本。
Clean up old versions of Gems with the cleanup
command. If you’re worried, you can see the results first with “dryrun”.
使用cleanup
命令cleanup
旧版本的Gems。 如果您担心,可以先使用“ dryrun”查看结果。
gem cleanup --dryrun
Then when you are confident, you can remove the “dryrun” param and run it for real.
然后,当您有信心时,可以删除“ dryrun”参数,然后对其进行实际运行。
gem cleanup
This depends specifically on your Ruby version manager. We’ll do two popular versions to help you out.
具体取决于您的Ruby版本管理器。 我们将提供两个受欢迎的版本来帮助您。
Using
rbenv
?使用
rbenv
吗?
List your installed versions with
rbenv versions
and then remove any withrbenv uninstall <versi
on>.列出具有
rbenv versions
已安装版本,然后通过rbenv uninstall <versi
on>删除所有rbenv versions
。
Using
rvm
?使用
rvm
吗?
List your installed versions with
rvm list
and then remove any withrvm uninstall <versi
on>.使用
rvm list
列出已安装的版本,然后使用rvm uninstall <versi
on>删除所有版本。
Xcode loves to cache things all over your machine, and some of these are hundreds of megs. Time to clean them up, and if you need to rebuild them again, no worries!
Xcode喜欢在整个计算机上缓存内容,其中一些是数百兆。 是时候清理它们了,如果您需要再次重建它们,请不用担心!
Clean up CocoaPod caches:
清理CocoaPod缓存:
rm -rf "${HOME}/Library/Caches/CocoaPods"
Delete old Xcode Simulators:
删除旧的Xcode模拟器:
xcrun simctl delete unavailable
Clean up various archives, logs, and derived data folders:
清理各种档案,日志和派生数据文件夹:
rm -rf ~/Library/Developer/Xcode/Archivesrm -rf ~/Library/Developer/Xcode/DerivedDatarm -rf ~~/Library/Developer/Xcode/iOS Device Logs/
Check out your connected device info in ~/Library/Developer/Xcode/iOS Device Logs/
and delete anything for old iOS devices you’ve connected.
在~/Library/Developer/Xcode/iOS Device Logs/
查看您已连接的设备信息,并删除已连接的旧iOS设备的所有内容。
You can remove all volumes not used by at least one container. Because… why would you want those?!
您可以删除至少一个容器未使用的所有卷。 因为……你为什么想要那些?
This might be huge or it might remove nothing. Worth a run right!?
这可能很大,也可能什么也没有清除。 值得一游吧!?
Remove unused local volumes
删除未使用的本地卷
docker volume prune
Don’t forget to empty your trash and check on how we did!
不要忘记清空您的垃圾并检查我们的工作方式!
30 GIGS! pulled off my machine! How about you?
30 GGGS! 拿走我的机器! 你呢?
Your success is probably vastly different, but I’d love to know. Comment or your results, and any other developer spots you recommend we clean! I’ll be happy to add your advice to the article.
您的成功可能有很大的不同,但我很想知道。 的结果发表评论或 ,以及我们建议您清除的其他开发人员建议! 我很乐意将您的建议添加到文章中。
is Chief Technology Strategist at , published author, adjunct professor, worldwide public speaker, and a mad scientist in training. Clap/follow/ or visit him .
( 是首席技术策略师,已发表的作者,兼职教授,全球演讲者和训练中的疯狂科学家。 拍手/跟随/ 或拜访他。
翻译自:
mac 释放空间
转载地址:http://kfwzd.baihongyu.com/