Skip to content
On this page

Mac 使用小记

电脑没声音,播放不出声音

  • 重启电脑声音
shell
sudo killall coreaudiod

设置mac光标移动速度

shell
defaults write NSGlobalDomain KeyRepeat -int 1

KeyRepeat对应的是按键重复,系统设置里调到最快对应的值是2,你可以调成0或者1(建议调为10可能会太快)

shell
defaults write NSGlobalDomain InitialKeyRepeat -int 15

InitialKeyRepeat对应的是重复前延迟,系统设置里调到最快对应的值是15,可以尝试调成10或者更小,不过建议保持15,因为反应时间太快会容易导致误操作(比如Esc键和Command-Z这样的快捷键)

安装软件失败问题解决

问题: 安装一些软件可能会出现这个报错:「xxx.app已损坏,打不开。你应该将它移到废纸篓」,并非你安装的软件已损坏,而是Mac系统的安全设置问题

解决方法:

shell
sudo spctl --master-disable

命令行关机

  • 立即关机
shell
sudo halt 或者 sudo shutdown -h now
  • 10分钟后关机
shell
sudo shutdown -h +10
  • 晚上8点关机
shell
sudo shutdown -h 20:00
  • 立即重启
shell
sudo reboot 
#或者 
sudo shutdown -r now

Mac中开启一个不存在跨域的Chrome窗口

TIP

/Users/username/Documents/ChromeDevUserData这个文件夹如果没有自己创建一个就行

shell
open -n /Applications/Google\ Chrome.app/ --args --disable-web-security  --user-data-dir=/Users/username/Documents/ChromeDevUserData

解决Mac升级为Big Sur系统后brew命令失效的问题

执行命令:

shell
brew update-reset

电脑连接WIFI失败

连接WIFI提示以下错误:

DANGER

Wi-Fi有自分配的IP地址"xxx.xxx.xxx.xxx",将无法接入互联网

原因:防火墙首选项很可能已损坏

解决方法如下:

参考文章:点击这里查看

  1. 删除系统偏好设置中安全面板中防火墙列表中的所有项目。

  2. 关闭防火墙。

  3. 删除应用程序防火墙首选项(位于Library/Preferences/com.apple.alf.plist)。

  4. 重启电脑,打开防火墙,重新配置设置。

homebrew下载软件出错

执行brew install xxx报错如下:

shell
fatal: Could not resolve HEAD to a revision
Warning: No available formula with the name "watchman".
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching for a previously deleted formula (in the last month).
Error: No previously deleted formula found.
==> Searching taps on GitHub...
Error: No formulae found in taps.

执行brew -v发现如下输出

shell
Homebrew 3.5.4
Homebrew/homebrew-core (no Git repository)
Homebrew/homebrew-cask (Git revision 9a5bb968b6; last commit 2022-07-12)

发现homebrew-core不存在

解决方法如下(参考链接):

  • 先诊断问题,执行brew doctor,输出如下:
shell
Warning: Homebrew/homebrew-core was not tapped properly! Run:
  rm -rf "/opt/homebrew/Library/Taps/homebrew/homebrew-core"
  brew tap homebrew/core

Warning: Some taps are not on the default Git origin branch and may not receive
updates. If this is a surprise to you, check out the default branch with:
  Git -C $(brew --repo homebrew/core) checkout master
  • 根据输出提示来修复问题

先执行:

shell
rm -rf /opt/homebrew/Library/Taps/homebrew/homebrew-core

再执行:

shell
brew tap homebrew/core

再次执行brew -v发现展示正常

shell
Homebrew 3.5.4-41-g8b3ff3d
Homebrew/homebrew-core (no Git repository)
Homebrew/homebrew-cask (Git revision 9a5bb968b6; last commit 2022-07-12)

如果还有第二个Warning的问题,再执行一次

shell
Git -C $(brew --repo homebrew/core) checkout master

Mac双开微信

shell
open -n /Applications/WeChat.app/Contents/MacOS/WeChat