V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
wsgzao
V2EX  ›  macOS

MacBook 使用指北

  •  
  •   wsgzao · 2018-07-25 17:43:15 +08:00 · 5950 次点击
    这是一个创建于 2100 天前的主题,其中的信息可能已经有所发展或是发生改变。


    ## 前言

    MacBook 刚拿到手,相信和各位一样有一个熟悉的过程,这里做下持续的更新记录

    > 学习使用 MacBook

    ## 更新历史

    2018 年 07 月 25 日 - 补充细节
    2018 年 07 月 05 日 - 初稿

    阅读原文 - https://wsgzao.github.io/post/macbook/

    **扩展阅读**

    Awesome Mac - http://wangchujiang.com/awesome-mac/index.zh.html

    ---

    ## System Preferences

    > 在任何的操作系统中,首先你需要做一件事就是更新系统,点击窗口左上角的  > 关于本机 > 软件更新 。此外,如果这是一部新的电脑,你还需要到系统设置进行一些适当调整。如何调整,取决于个人喜好。

    ### 触控板

    系统设置 > 触控板

    光标与点击
    - 轻拍来点按
    - 辅助点按
    - 查找
    - 三指拖移

    滚动缩放
    - 默认全选

    更多手势
    - 默认全选

    ### Dock

    置于屏幕上的位置:左边
    设置 Dock 图标更小(大小随个人喜好)
    ✓ 自动显示和隐藏 Dock

    ### Finder

    Finder > 显示
    - 显示标签页栏
    - 显示路径栏
    - 显示状态栏
    - 自定工具栏 > 去除所有按钮,仅剩搜索栏

    Finder > 偏好设置

    通用
    - 开启新 Finder 窗口时打开:HOME 「用户名」目录

    边栏
    - 添加 HOME 「用户名」目录 和 创建代码文件目录
    - 将 共享的(shared) 和 标记(tags) 目录去掉

    ### 菜单栏

    去掉蓝牙等无需经常使用的图标
    将电池显示设置为百分比

    ### Spotlight

    去掉字体和书签与历史记录等不需要的内容
    设置合适的快捷键

    ### 互联网帐户

    添加 iCloud 用户,同步日历,联系人和 Find my mac 等等

    ### English

    Trackpad
    - Tap to click

    Accessibility -> Mouse & Trackpad -> Trackpad Options
    - Enable dragging | three finger drag

    Language & Region
    - Time format | 24-Hour Time
    - click add button | Chinese, Simplified

    Language & Region -> Keyboard Preferences -> Shortcuts -> Input Sources
    - Select the previous input source

    Display -> Arrangement
    - Drag the graphics and just make what you want
    - if the display rotates 90 degrees then change Rotation to 90° or 270° and click confirm button to save

    ## Mac 键盘快捷键

    https://support.apple.com/zh-cn/HT201236

    Command ⌘
    Shift ⇧
    Option ⌥
    Control ⌃
    Caps Lock ⇪
    Fn

    > 我自己常用的快捷键

    快捷键 | 描述
    --- | ---
    Command(⌘)-C | 复制
    Command(⌘)-V | 粘贴
    Command(⌘)-Z | 撤销
    Command(⌘)-Option-V | 剪切粘贴
    Command(⌘)-A | 全选
    Command(⌘)-F | 查找
    Command(⌘)-S | 保存
    Command(⌘)-W | 关闭当前窗口
    Command(⌘)-空格键 | 聚焦
    Command(⌘)-方向左键 | 后退
    Command(⌘)-方向右键 | 前进
    Control-A | 移至行或段落的开头
    Control-E | 移至行或段落的末尾
    Control-空格键 | 切换输入法(需要手动设置)
    Control – Command-Q | 系统自带锁屏快捷键

    ## Mac Soft

    Homebrew
    https://brew.sh/

    Mounty for NTFS
    http://enjoygineering.com/mounty/

    Sougou Input - Sogou
    https://pinyin.sogou.com/mac/

    Youdao Dict - Netesse
    http://cidian.youdao.com/index-mac.html

    Jietu - Tencent
    http://jietu.qq.com/

    Kantu - Tencent
    https://kantu.qq.com/

    f.lux
    https://justgetflux.com/

    Foxit Reader
    https://www.foxitsoftware.com/pdf-reader/

    Evernote
    https://evernote.com/

    Dropbox
    https://www.dropbox.com/

    Keka
    https://www.keka.io/en/

    FOLX
    https://mac.eltima.com/download-manager.html

    IINA
    https://lhc70000.github.io/iina/

    Sourcetree
    https://www.sourcetreeapp.com/

    Microsoft Remote Desktop
    https://itunes.apple.com/us/app/microsoft-remote-desktop-10/id1295203466?mt=12

    VMware OS Optimization Tool
    https://labs.vmware.com/flings/vmware-os-optimization-tool

    ### Homebrew

    https://docs.brew.sh/Installation

    ``` bash
    # install xcode first
    https://itunes.apple.com/us/app/xcode/id497799835

    # install homebrew
    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

    # install packages
    brew install zsh
    brew install wget
    brew install git
    # default install is python3 now, if you need python2 just run `brew install python2`
    brew install python

    ```

    ### iTerm2 + zsh + Oh My Zsh

    iTerm2
    https://www.iterm2.com/

    Oh My Zsh
    http://ohmyz.sh/

    ``` bash
    # install latest zsh zsh-syntax-highlighting
    brew install zsh zsh-syntax-highlighting
    # 修改默认 shell,在 /etc/shells 文件中加入如下一行
    vi /etc/shells

    /usr/local/bin/zsh
    # 然后运行命令切换 shell
    chsh -s /usr/local/bin/zsh

    # install oh-my-zsh
    sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

    # 修改主题为 agnoster,增加一行 zsh-syntax-highlighting
    vi ~/.zshrc

    ZSH_THEME="agnoster"
    source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

    # 可选增加 visual studio code 命令行 code 支持 zsh
    function code {
    if [[ $# = 0 ]]
    then
    open -a "Visual Studio Code"
    else
    local argPath="$1"
    [[ $1 = /* ]] && argPath="$1" || argPath="$PWD/${1#./}"
    open -a "Visual Studio Code" "$argPath"
    fi
    }

    # 解决 Too many files open error
    ulimit -n 10000
    ulimit -u 2048

    # 刷新环境变量
    source ~/.zshrc

    # 安装 powerline 字体
    git clone https://github.com/powerline/fonts.git
    cd fonts
    ./install.sh

    ```

    > 配置 iTerm2 主题,主题可以从 iterm2colorschemes 下载

    https://iterm2colorschemes.com/

    1. Download iTerm2 color you like
    2. Open iTerm2 that we already downloaded at the first section
    3. Go to iTerm2 > Preferences > Profiles > Colors Tab
    4. Click Color Presets at the bottom right
    5. Click Import
    6. Select the *.itermcolors file
    7. Select the * from Load Presets

    在 Keys -> Hotkey 中设置 `command + i` 快速显示和隐藏 iTerm
    在 Profiles -> Default -> Colors -> Load Presets 导入主题,作为默认颜色,我的主题是`3024 Night`
    在 Profiles -> Text -> Change Font 调整字体 /大小 /颜色等,我的字体是`18pt Ubuntu Mono derivative Powerline`

    ## Others

    ### 更改 Apple ID 国家或地区

    > 区域在国内即使身在国外也看不到你需要的很多东东,建议修改

    https://support.apple.com/zh-cn/ht201389

    ### USB Type-C 耳机

    1. 插入耳机至任意 USB Type-C 接口
    2. System Preferences -> Sound -> Output -> 选择识别到的耳机设备即可

    ### 配置从命令提示行启动 vscode

    安装 Visual Studio Code,打开命令面板(按 F1 或 command + shift + p )输入 Shell 命令找到 Shell 命令: 在 PATH 中安装“ code ”命令。命令执行完成之后,重启终端工具使新的$PATH 可用。现在,您可以简单地在终端中任意文件夹下输入‘ code .’来编辑该文件夹下的文件了。

    ### Git Ignore

    ``` bash
    # 创建一个新文件 ~/.gitignore,并将以下内容添加进去,这样全部 git 仓库将会忽略以下内容所提及的文件。

    # Folder view configuration files
    .DS_Store
    Desktop.ini

    # Thumbnail cache files
    ._*
    Thumbs.db

    # Files that might appear on external disks
    .Spotlight-V100
    .Trashes

    # Compiled Python files
    *.pyc

    # Compiled C++ files
    *.out

    # Application specific files
    venv
    node_modules
    .sass-cache

    ```

    ### 禁止.DS_store 生成

    ``` bash
    # 禁止 .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 {} \;

    ```

    ### ssh 相关

    ``` bash
    # -bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
    # 禁止 OpenSSH 客户端从 OS X/Linux/Unix 桌面发送 LC_*变量
    vi /etc/ssh/ssh_config
    #SendEnv LANG LC_*

    # port forwarding
    ssh -p 22202 [email protected]
    ssh -p 22202 [email protected] -X
    scp -P 22202 -r sysctl.sh sysctl.d/ [email protected]:/tmp

    # ssh tunnel for one-time
    ssh -t -A [email protected] ssh [email protected]

    # config ssh tunnel to make easy connect everyday
    vim ~/.ssh/config

    StrictHostKeyChecking=no

    Host 10.65.32.*
    HostName %h
    ProxyCommand ssh bastion_GOP_SG_NC_MAIN -W %h:%p
    Host bastion_GOP_SG_NC_MAIN
    HostName 8.8.8.8
    port 22
    User wangao

    # test
    ssh 10.65.32.60



    ```
    14 条回复    2018-07-26 10:17:03 +08:00
    LagunAPaTa
        1
    LagunAPaTa  
       2018-07-25 21:15:04 +08:00
    ThinkCenter
        2
    ThinkCenter  
       2018-07-25 22:15:51 +08:00
    已阅,准奏。
    strugglexiang
        3
    strugglexiang  
       2018-07-25 22:45:49 +08:00 via Android
    zj299792458
        4
    zj299792458  
       2018-07-25 23:45:02 +08:00 via Android
    网络村村通?
    cyn
        5
    cyn  
       2018-07-25 23:50:50 +08:00 via Android
    为什么不是指南?
    agagega
        6
    agagega  
       2018-07-25 23:53:02 +08:00 via iPhone
    给封面凯馨妹子点个赞
    ftu
        7
    ftu  
       2018-07-26 00:06:28 +08:00 via iPhone
    好奇怪没有以 md 显示
    Yien
        8
    Yien  
       2018-07-26 01:49:49 +08:00 via Android
    好厉害的样子!
    iPhone8
        9
    iPhone8  
       2018-07-26 01:55:38 +08:00
    我晕,我第一次看到这个帖子的时候还没人回复,以为 markdown 会编辑一下。

    然后现在楼上 8 个人回复了,竟然还没修改。。。
    babytomas
        10
    babytomas  
       2018-07-26 09:43:20 +08:00
    一眼看到帖子的名字带「指北」,还以为是在骂人 。。。
    maemolee
        11
    maemolee  
       2018-07-26 09:46:16 +08:00
    同样都是 Markdown,只有你是把源文件放出来🤔
    DemonLee
        12
    DemonLee  
       2018-07-26 09:47:23 +08:00
    awesome, mark!
    qiuyun8m
        13
    qiuyun8m  
       2018-07-26 10:15:43 +08:00
    DansonL
        14
    DansonL  
       2018-07-26 10:17:03 +08:00
    @babytomas 客家人
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1098 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 108ms · UTC 19:10 · PVG 03:10 · LAX 12:10 · JFK 15:10
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.