MacBook Air 新机开发环境安装 - iTerm2、oh my zsh、浏览器插件等

499 阅读1分钟

好的设置极大提高工作效率。本文是在国内无法访问 google 情况下,故本文的搜索均指 bing。

homebrew

搜索 homebrew,通过 curl 方式下载,如果提示无法连接 raw.githubusercontent.comgithub.com/521xueweiha…

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

nvm

brew instlal fnm 安装会导致 node -v 没法使用,因为其安装到目录没有自动加到 bin 目录。故还是安装 nvm 更省心。

同样通过 curl 安装。

git

git config --get init.defaultBranch 如果不是你倾向于的 master。可以设置:

git config --global init.defaultBranch master

iTerm2

搜索并下载即可

设置

如何打开新 tab / window 仍然延续当前的目录

比如 tab A 目录是 ~/workspace/helloCMD+T / CMD+N 打开的新 tab / window 仍然默认进入 ~/workspace/hello 目录

设置:

  1. iTerm2 → Preferences → Profiles.
  2. In “Working Directory” section select “Reuse previous session's directory”

参考 medium.com/ayuth/new-t…

oh my zsh

通过 curl 安装即可。

插件

搜索 zsh 使用 zsh 安装方式,即 git clone + 手动设置 .zshrc

plugins=(
  git
  # git-plus
  zsh-syntax-highlighting
  zsh-autosuggestions
)

主题

使用 starship

~/.zshrc

# https://github.com/starship/starship
eval "$(starship init zsh)"

# function set_win_title(){
#     echo -ne "\033]0; $(basename "$PWD") \007"
# }
# starship_precmd_user_func="set_win_title"

配置

❯ cat ~/.config/starship.toml
[nodejs]
symbol = "🦄 "
# symbol = "nodejs 🦄 "
# symbol = "nodejs 🦄 🚀 "

[git_branch]
symbol = "🌱 "
# symbol = "🌱 ☘️ 🌿 🌾 "

浏览器

下载 Google Chrome 浏览器。比较坎坷

zhuanlan.zhihu.com/p/650252035

插件

比较坎坷

www.crxsoso.com

1. clut

www.crxsoso.com/webstore/de…

  • 如果无法下载,需要同意允许从该站点下载。
  • 如果无法安装,需要 chrome://extensions 打开开发者模式。然后将下载的 crx 文件拖动到插件管理页面即可。
设置

自定义快捷键,比如将 Alt+W 改成 Alt+Q,打开 chrome://extensions/shortcuts 修改即可。

技巧:可以通过拼接插件 id 直接进入国内的插件页面。

1. Tampermonkey

同理安装即可。

设置

通用 - 配置模式 - 高级

编辑器

  • 锁进 2 空格
  • 编辑器失去焦点时保存内容

Userscript 模版 ECMAScript 5

github.com/legend80s/t…

// ==UserScript==
// @name         New Userscript
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  try to take over the world!
// @author       legend80s
// @match        <$URL$>
// @icon         <$ICON$>
// @grant        none
// ==/UserScript==

// CHANGELOG
// 1.0 初始化
(async function() {
  'use strict';

  // Your code here...
  // https://github.com/legend80s/tampermonkey/blob/master/utils.js
  const {
    $,
    $$,
    ready,
    createLoggers,
    time2Readable,
    onUrlChange,
    // eslint-disable-next-line no-undef
  } = tampermonkeyUtils;

  const { log } = createLoggers(GM_info);

  main()

  async function main() {
    init()

    onUrlChange(() => init())
  }

  async function init() {
    const begin = Date.now();

    await ready('iframe');

    const ifs = $$('iframe[src^=http]');

    ifs.forEach(f => f.remove());

    log('🎉 移除', ifs.length, '个 iframe。耗时', time2Readable(begin, Date.now()))
  }
})();