macos初始化设置


安装homebrew

  • 安装命令行tools

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

  • 执行安装

    ruby brew_install

homebrew cask

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

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

brew rmtree emacs

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

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

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

切换中国源

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

恢复官方源

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

brew更新

  • 更新brew

    brew update -v

    注:-v可显示更新进度

  • 列出可更新

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

    brew upgrade go git node
    brew cask upgrade steam

macos使用深色菜单栏

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

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

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

再执行第 3 步即可

安装powerline字体

brew cask install font-inconsolata-for-powerline

终端设置字体,重启终端

禁止.DS_store生成

# 禁止 .DS_store 生成,打开“终端”,复制黏贴下面的命令,回车执行,重启 Mac 即可生效。
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool TRUE
# 恢复 .DS_store 生成
defaults delete com.apple.desktopservices DSDontWriteNetworkStores
# 刪除已存在的. DS_Store
sudo 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

printf '\e[?2004l'

重装CommandLineTools

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

查看监听端口

sudo lsof -nP -iTCP | grep LISTEN

osascript记录

获取当前输入法

  • 方式一

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

    return value of attribute "AXDescription" of currentLayout

菜单是否选中

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

字符串对比

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

获取菜单参数

  • 方式一

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

    # 获取所有
    return attributes of currentLayout
    return value of attributes of currentLayout
    # 获取单个
    return value of attributes "AXMenuItemMarkChar" of currentLayout
作者: honmaple
链接: https://honmaple.me/articles/2019/07/macos初始化设置.html
版权: CC BY-NC-SA 4.0 知识共享署名-非商业性使用-相同方式共享4.0国际许可协议
wechat
alipay

加载评论