zl程序教程

您现在的位置是:首页 >  Java

当前栏目

程序员必备小技能:mac文件备份和清理、常用工具的安装和配置

2023-02-18 16:34:23 时间

引言

一年一度的iOS 系统 API适配来了,9 月 14 日起 App Store Connect 已经开放 iOS 15 和 iPadOS 15 App 的提交,同时苹果宣布自 2022 年 4 月起,所有提交至 App Store 的 iOS 和 iPadOS app 都必须使用 Xcode 13 和 iOS 15 SDK 构建。

Xcode 13 正式版包含 iOS 15,iPadOS 15,tvOS 15,watchOS 8 以及 macOS Big Sur 11.3 SDK。Xcode 13 需在 macOS 11.3 及以上版本运行,支持 iOS 9,tvOS 9,watchOS 2 及以上系统设备调试; 也正式支持了 Vim。 Xcode 13 Release Notes: https://developer.apple.com/documentation/xcode-release-notes/xcode-13-release-notes

正是基于近期iOS15出来了,需要升级IDE进行适配。发现磁盘空间不足,连操作系统都无法升级了。

目前使用的Mac磁盘空间是121GB,至少需要换256G的。

可见平时的Mac清理的重要性,于是乎分享下更换Mac时的备份和清理小知识。

经常备份重要的配置和文件是良好的习惯,尤其当你Mac的配置跟不上开发要求的时候显得尤其重要。

I、备份

1.1 备份软件/工具

  • alfredapp

https://www.alfredapp.com/help/

  • charlesproxy

https://www.charlesproxy.com 4.2

  • oh-my-zsh:https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH
  • SmartPush

1.2 备份配置

  • ~/Library/Developer/Xcode/UserData/CodeSnippets

https://download.csdn.net/download/u011018979/12852517

  • ~/.ssh/config
  • ~/.bash_profile
#多开WeChat
alias wx='nohup /Applications/WeChat.app/Contents/MacOS/WeChat > /dev/null &'

1.3 备份代码/常用脚本

  • ~/bin

1.4 备份常用浏览器扩展/网站

推荐登录Google账号选择同步数据(扩展、书签)

  • CSDN插件自带广告屏蔽,可自定义添加个人常用站点(记得手动备份)。
  • Axure RP Extension for Chrome(查看原型)
  • Markdown Nice (支持自定义样式的 Markdown 编辑器)
  • 新榜小助手(为公众号运营者提供广告接单变现与运营工具服务)
  • https://lanhuapp.com/xd
  • https://git.weixin.qq.com/users/authorize#wechat_redirect
  • 风_车_云_马

II、清理

2.1 清理个人信息

  • 退出appID
  • 清理浏览器记住的密码

  • 清理浏览器扩展
  • 清理社交app(包括企业微信)

2.2 清理Xcode产生的调试文件

安装Xcode的时候,由于公司的Mac经常提示”可用的磁盘空间不足,无法安装此产品。“,因此记录一下。

在这里插入图片描述

如果从AppStore升级Xcode失败的话,可通过URL下载Xcode

Xcode12:https://download.developer.apple.com/Developer_Tools/Xcode_12/Xcode_12.xip 同理:11 直接修改URL参数即可

https://download.developer.apple.com/Developer_Tools/Xcode_11/Xcode_11.xip

https://download.developer.apple.com/Developer_Tools/Xcode_10/Xcode_10.xip

  • 清理脚本
#!/bin/sh
# The ~/Library/Developer/Xcode/iOS DeviceSupport folder is basically only needed to symbolicate crash logs.
# You could completely purge the entire folder. Of course the next time you connect one of your devices, Xcode would redownload the symbol data from the device.
# I clean out that folder once a year or so by deleting folders for versions of iOS I no longer support or expect to ever have to symbolicate a crash log for.
killall -9 Xcode
killall -9 com.apple.CoreSimulator.CoreSimulatorService

rm -rf ~/Library/Developer/Xcode/iOS\ DeviceSupport/*
rm -rf ~/Library/Developer/Xcode/DerivedData/*
rm -rf ~/Library/Developer/Xcode/Archives/*
rm -rf ~/Library/Developer/Xcode/Products/*

rm -rf ~/Library/Developer/CoreSimulator/Devices/*

killall -9 com.apple.CoreSimulator.CoreSimulatorService
killall -9 Xcode
rm -rf ~/.Trash/
exit 0%      

2.3 清理缓存

open ~/Library/Caches

2.4 关闭TimeMachine

在这里插入图片描述

3.4 磁盘空间管理

在这里插入图片描述

以我的Mac为例子,Mac系统能清理的只有文稿和应用程序,系统和其他占据了87G是无法清理的。

III、常用工具的安装

  1. 安装Homebrew: /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
  2. 安装zsh 安装方式1:brew install zsh安装方式2:
 git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
 cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc

# <!--  修改主题 -->
 open ~/.zshrc 
# 修改 `ZSH_THEME=”robbyrussell”`,主题在 ~/.oh-my-zsh/themes 目录下。

在~/.zshrc 引用bash的配置source ~/.bash_profile

配置bash的时候,采用~/.bash_profile;配置zsh的时候,采用open ~/.zshrc

  1. 安装autojump:brew install autojump

autojump是一个命令行工具,它可以使用快捷命令,直接跳转到配置好的目录,而不用管现在身在何处,依赖zsh。j -a 你定义的快捷命令 ‘需要跳转的目录位置’

使用vim ~/.zshrc

a. 找到 plugins=,在后面添加autojump:plugins=(git autojump) b. 新开一行,添加:[[ -s (brew --prefix)/etc/profile.d/autojump.sh ]] && .

(brew --prefix)/etc/profile.d/autojump.sh c. :wq保存退出,重启终端。

plugins=(
  git autojump
)

[[ -s $(brew --prefix)/etc/profile.d/autojump.sh ]] && . $(brew --prefix)/etc/profile.d/autojump.sh
  1. 安装cocoapods:sudo gem install cocoapods

IV、常用的配置

显示/隐藏 文件

alias fs='defaults write com.apple.finder AppleShowAllFiles -boolean true ; killall Finder'
alias fh='defaults write com.apple.finder AppleShowAllFiles -boolean false ; killall Finder'

设置git名称及对应的邮箱:git config --global --edit

see also

connecting-to-github-with-ssh 免密码进行SSH连接

【Mac 使用~/.ssh 的config 配置GitHub SSH keys】同样适用于gitlab 原文链接:https://blog.csdn.net/z929118967/article/details/78234772 ———————————————— 版权声明:本文为CSDN博主「iOS逆向」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。

清理Mac文件