macos初始化设置


安装homebrew

  • 安装命令行tools

    1xcode-install
    1curl >> brew_install
  • 修改REPO地址

  • 执行安装

    1ruby brew_install

homebrew cask

使用git clone 中科大到指定目录

homebrew卸载依赖, 使用homebrew tap xxx/rmtree

1brew rmtree emacs

App Store 安装 QQ,微信,网易云音乐 Brew cask 安装 git, google-chrome, virtualbox, shadowsocksx-ng,emacs

拷贝文件,使用共享里的远程管理, 在原机器Linux下ssh到macbookpro,或者使用scp

修改电脑名,在设置共享里

切换中国源

1git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
2git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
3git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
4brew update -v

恢复官方源

1git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git
2git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git
3git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask.git
4brew update -v

brew更新

  • 更新brew

    1brew update -v

    注:-v可显示更新进度

  • 列出可更新

    1brew outdated
    2brew cask outdated --greedy
  • 更新软件

    1brew upgrade go git node
    2brew cask upgrade steam

移除后台服务

可以查找下列目录并删除相关文件

1/Library/LaunchAgents
2/Library/LaunchDaemons
3~/Library/LaunchAgents
4~/Library/LaunchDaemons

macos使用深色菜单栏

1.在「系统偏好设置 - 通用」中将外观切换成「浅色」。 2.打开终端,输入指令:defaults write -g NSRequiresAquaSystemAppearance -bool Yes 3.注销并重新登录。这一步会关闭当前所有打开的应用,因此需要提前保存好所有文稿。 4.在「系统偏好设置 - 通用」中将外观切换成「深色

如果你想要恢复成默认的深色模式,那么在终端中输入

1defaults write -g NSRequiresAquaSystemAppearance -bool No
2defaults delete -g NSRequiresAquaSystemAppearance

再执行第 3 步即可

安装powerline字体

1brew cask install font-inconsolata-for-powerline

终端设置字体,重启终端

禁止.DS_store生成

1# 禁止 .DS_store 生成,打开“终端”,复制黏贴下面的命令,回车执行,重启 Mac 即可生效。
2defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool TRUE
3# 恢复 .DS_store 生成
4defaults delete com.apple.desktopservices DSDontWriteNetworkStores
5# 刪除已存在的. DS_Store
6sudo find . -name ".DS_Store" -depth -exec rm {} \;

移动文件

https://sspai.com/post/28389

选中目标文件,然后使用 Command+C 复制,然后用 Command +Option+V 将其移动到目标目录。

复制文本到终端出现00~xxxx01~字符

https://stackoverflow.com/questions/44848979/getting-strange-characters-when-pasting-into-my-iterm2-terminal

1printf '\e[?2004l'

重装CommandLineTools

1sudo rm -rf /Library/Developer/CommandLineTools
2xcode-select --install

查看监听端口

1sudo lsof -nP -iTCP | grep LISTEN

osascript记录

获取当前输入法

  • 方式一

    1osascript << EOF
    2tell application "System Events"
    3    tell process "TextInputMenuAgent"
    4        set currentLayout to menu bar item 1 of menu bar 2
    5    end tell
    6    return description of currentLayout
    7end tell
    8EOF
  • 方式二

    1return value of attribute "AXDescription" of currentLayout

菜单是否选中

1osascript << EOF
2tell application "System Events"
3        tell process "TextInputMenuAgent"
4            set currentLayout to menu item "ABC" of menu 1 of menu bar item 1 of menu bar 2
5        end tell
6        return value of attribute "AXMenuItemMarkChar" of currentLayout as string is not "missing value"
7end tell
8EOF

字符串对比

1return description of currentLayout is not "ABC"
2return description of currentLayout as string = "ABC"

获取菜单参数

  • 方式一

    1# 获取所有
    2return properties of currentLayout
    3# 获取单个
    4return description of currentLayout
  • 方式二

    1# 获取所有
    2return attributes of currentLayout
    3return value of attributes of currentLayout
    4# 获取单个
    5return value of attributes "AXMenuItemMarkChar" of currentLayout

禁用Chrome更新

1cd ~/Library/Google/
2sudo rm -rf GoogleSoftwareUpdate
3sudo mkdir GoogleSoftwareUpdate
4sudo chown root:wheel GoogleSoftwareUpdate
5defaults write com.google.Keystone.Agent checkInterval 0

如果上述方式无效, 再尝试

1cd ~/Library/Application\ Support/Google/
2mv GoogleUpdater GoogleUpdater.old
3mkdir GoogleUpdater
4sudo chown root:wheel GoogleUpdater

Too many open files

https://superuser.com/questions/433746/is-there-a-fix-for-the-too-many-open-files-in-system-error-on-os-x-10-7-1

  1. 创建配置

    1sudo emacs -nw /Library/LaunchDaemons/limit.maxfiles.plist
  2. 输入内容

     1<?xml version="1.0" encoding="UTF-8"?>
     2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
     3"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
     4<plist version="1.0">
     5  <dict>
     6    <key>Label</key>
     7    <string>limit.maxfiles</string>
     8    <key>ProgramArguments</key>
     9    <array>
    10      <string>launchctl</string>
    11      <string>limit</string>
    12      <string>maxfiles</string>
    13      <string>64000</string>
    14      <string>102400</string>
    15    </array>
    16    <key>RunAtLoad</key>
    17    <true/>
    18    <key>ServiceIPC</key>
    19    <false/>
    20  </dict>
    21</plist>
  3. 使配置生效

    1sudo launchctl load -w /Library/LaunchDaemons/limit.maxfiles.plist
  4. 验证修改

    1launchctl limit maxfiles
作者: honmaple
链接: https://honmaple.me/articles/2019/07/macos初始化设置.html
版权: CC BY-NC-SA 4.0 知识共享署名-非商业性使用-相同方式共享4.0国际许可协议
wechat
alipay

加载评论