整理一些苹果电脑的实用小技巧, 包括曾经踩过的坑。
InsomniaX 防止 mac OS 休眠
Disable lid sleep 禁止合盖睡眠
Disable idle sleep 禁止闲置睡眠
disable lid sleep when on ac 使用交流电时禁止合盖睡眠
自启动服务
原生自启动
-
如果需要 root,并且是需要用户登陆后才能运行,把 plist 放在 /Library/LaunchAgents/
-
如果需要 root,并且不需要用户登陆后都能运行,把 plist 放在 /Library/LaunchDaemons/
显示当前的启动脚本
launchctl list
开机时自动启动Apache服务器
sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist
sudo launchctl load -w /Library/LaunchDaemons/frpc.plist
设置开机启动并立即启动服务
launchctl load -w **.pist
设置开机启动但不立即启动服务
launchctl load **.pist
停止正在运行的启动脚本
sudo launchctl unload [path/to/script]
再加上-w选项即可去除开机启动
sudo launchctl unload -w [path/to/script]
brew 安装的自启动
brew services start redis
必须先安装
brew tap gapple/services
brew services cleanup service-name
brew services list
start and stop redis
location: /opt/homebrew/etc/redis.conf
redis-server
redis-cli shutdown
vscode 提示不能在只读卷上升级问题
sudo chown -R $USER ~/Library/Caches/com.microsoft.VSCode.ShipIt
xattr -dr com.apple.quarantine /Applications/Visual\ Studio\ Code.app
配置终端颜色及提示(.zshrc)
export CLICOLOR='Yes'
autoload -U colors && colors
PROMPT="%{$fg[green]%}%n@%m%{$reset_color%} %{$fg[blue]%}%1~%{$reset_color%} %# "
搜出所有包含 frpc 的文件
mdfind -name “frpc”
unicode to utf8
iconv -f GBK -t UTF-8 qyn.txt>> qyn2.txt
vscode vim 长按键光标移动问题
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
or
defaults write -g ApplePressAndHoldEnabled -bool false
开启任何来源代码
sudo spctl --master-disable
移除quarantine属性代码
sudo xattr -r -d com.apple.quarantine xxx.dmg
制作usb启动盘
方案1: 已安装的可视化工具
balenaetcher
方案2
1、制作mac格式的镜像
hdiutil convert -format UDRW -o ubuntu.iso ubuntu-14.04.5-desktop-amd64.iso
2、卸载U盘
diskutil list 查看u盘盘符
diskutil unmountDisk /dev/disk2
3、镜像拷贝
mv ubuntu.iso.dmg ubuntu.iso
sudo dd if=./ubuntu.iso of=/dev/disk2 bs=1m>
#这行命令必须使用root权限, if:输入的文件名 of:输出的文件名* bs:是块大小,这里使用1m的块大小。
4、退u盘
sudo eject /dev/disk2
5、销毁数据,随机数填充 sudo dd if=/dev/urandom of=/dev/rdisk2