一. tar 打包参入私货
MacOS 使用的是非 gnu 的 tar 打包命令, 打包时会带入一些小惊喜, 导致你在其它平台解包的时候报类似: tar: 忽略未知的扩展头关键字‘LIBARCHIVE.xattr.com.apple.provenance’ 的错误.
解决这个问题的很简单, 使用 gnu-tar 就行;
brew install gnu-tar
使用也很简单:
gtar czf xxx.tar.gz xxx/
但是这样使用我还得多用个 g, 既然是要替代原始的 tar, 那就 g 占 t 巢吧
在 ~/.zshrc (取决你使用的 shell 环境) 文件里添加以下命令:
alias tar='gtar'
然后
source ~/.zshrc
二. 控制 macos 到处拉文件 .DS_Store 之类的
2.1 控制在网络共享目录/U 盘生成 .DS_Store 之类的文件
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true # 网络盘
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true # USB 盘(macOS 10.15+ 支持)
然后执行 killall Finder 生成
2.2 禁止聚焦 (Spotlight) 在 U 盘建索引
聚焦会在 U 盘生成 .Spotlight-V100 文件
执行以下命令:
sudo mdutil -i off "/Volumes/你的磁盘名字"
sudo mdutil -X "/Volumes/你的磁盘名字"
提示文件删除表示成功了