# 前言

一些开发环境的快捷键及工具

# centos 安装cmake gcc开发环境

yum install make automake gcc gcc-c++ kernel-devel

参见: https://unix.stackexchange.com/questions/1338/what-is-the-fedora-equivalent-of-the-debian-build-essential-package (opens new window)

# iterm2 + oh my zsh

iterm2下载安装即可:https://iterm2.com/downloads.html (opens new window) oh my zsh参见:https://a1049145827.github.io/2019/05/15/Mac-环境安装并配置终端神器-oh-my-zsh/ (opens new window)

主要命令如下:

# 安装ohmyzsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

如果是centos8之类的默认不包含zsh,还需要自己安装zsh:

yum -y install zsh git
chsh -s (which zsh) root
# 此时~/.zshrc并不存在,安装完oh-my-zsh之后,需要自己copy一下
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
source ~/.zshrc

语法高亮和命令提示插件:

# zsh-syntax-highlighting
# git@github.com:zsh-users/zsh-syntax-highlighting.git
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
# zsh-autosuggestions
# git@github.com:wting/autojump.git
git clone https://github.com/zsh-users/zsh-autosuggestions.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

autojump:

# 如果是mac
brew install autojump
# 如果是centos
# git@/github.com:wting/autojump
git clone https://github.com/wting/autojump.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/autojump
python3 ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/autojump/install.py

autojump 还需要按照提示在 ~/.zshrc 中添加2行配置:

[[ -s /root/.autojump/etc/profile.d/autojump.sh ]] && source /root/.autojump/etc/profile.d/autojump.sh
autoload -U compinit && compinit -u

如果运行 autojump 报找不到python的错,运行这行代码:

ln -s /usr/bin/python3 /usr/bin/python

修改 ~/.zshrc 的plugins:

plugins=(
  git
  last-working-dir
  zsh-autosuggestions
  zsh-syntax-highlighting
)

# Alfred

插件:

  • Copy Path
  • NewFile
  • alfred-ip-address-workflow
  • Host-Switch-Alfred
  • Youdao Translate
  • Open with VS Code

# git

多host,配置~/.ssh/config

# gitee
Host gitee.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/xxx
# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/xxx

多gitconfig,使用includeIf:

[alias]
 ck = checkout
 st = status
 bc = branch
 cm = commit
[user]
    name = Thyiad
 email = 1520583107@qq.com
[includeIf "gitdir:/Users/taohongyong/Documents/project/xxx/"]
    path = /Users/taohongyong/.xxx_gitconfig

网络问题无法下载github仓库时,可以使用代理,比如 ghproxy.com

git clone https://ghproxy.com/https://github.com/stilleshan/ServerStatus
curl -O https://ghproxy.com/https://github.com/stilleshan/ServerStatus/archive/master.zip

# node.js

  • nvm/n

    node.js 版本管理 curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash 如果有网络问题,就运行这行代码设置安装node时的代理 export NVM_NODEJS_ORG_MIRROR=https://npmmirror.com/mirrors/node

  • nrm

    切换npm源

  • http-server

    本地起一个静态资源服务器

    npm install -g http-server
    http-server . -p 8080
    
  • npx

    方便调用项目的依赖模块

    npx jest # 直接调用node_modules中的jest而不需要手动编写npm script
    npx create-react-app app # npx 将create-react-app下载到一个临时目录,使用以后再删除。使得你不需要全局安装
    ls -al
    
  • optimist

    解析命令行参数

    var argv = require('optimist').argv;
    
  • yargs

    开发命令行工具

  • cloc

    快速统计指定文件夹下的代码数据

    cloc --exclude-dir=node_modules . --exclude-ext=json,html
    
  • promisify

    node.js的官方api,把callback包装成promise,只要符合最后一个参数是callback,并且callback第一个参数是错误处理的API都可以

    const { promisify } = require('util')
    const { exec } = require('child_process')
    const execWithPromise = promisify(exec)
    
  • npm link

    调试模块

    cd vue // 进入本地clone下来的vue文件夹
    npm link // 如果没有全局安装过vue 此时会创建全局node_modules下的一个软链接vue指向本地clone的vue入口文件
    npm link vue // 在需要用调试vue模块的应用执行该命令会将当前应用的node_modules/vue指向全局node_modules/vue软链接
    npm unlink vue    // 在应用中执行该命令去除该link
    npm unlink    // 在包目录中去除该link