mac环境下前端开发环境及终端设置

978 阅读1分钟

brew

必备 例如:brew case install firefox

brew.sh/index_zh-cn…

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

安装brew过程会很慢,安装后每次install都会Updating Homebrew,很烦,所以在~/.zshrc进行如下操作

# open ~/.zshrc
# 在文件中添加如下

# 关闭自动更新 Updating Homebrew
export HOMEBREW_NO_AUTO_UPDATE=true

git 安装

brew install git 

git 初始化配置

执行以下操作,将生成的公匙粘贴到git头像下settings SSH and GPG keys

cd ~/.ssh
ssh-keygen -t rsa -C 'youremail@qq.com' # 连续三个enter 可以增加参数 -b 4096增加安全性
cat ~/.ssh/id_rsa.pub # 查看公匙

git上传代码报错ssh: connect to host github.com port 22: Connection timed out解决办法

ssh -T git@github.com
cd ~/.ssh 
ls
# 查看是否存在 id_rsa   id_rsa.pun  known_hosts 三个文件,如果没有则看上面初始化方法
touch config
vim config

# Host github.com
# User YourEmail@163.com
# Hostname ssh.github.com
# PreferredAuthentications publickey
# IdentityFile ~/.ssh/id_rsa
# Port 443

# 继续执行,验证
ssh -T git@github.com

# 出现以下则表示成功
$ ssh -T git@github.com 
# The authenticity of host '[ssh.github.com]:443 ([192.30.253.122]:443)' can't be established.
# RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
# Are you sure you want to continue connecting (yes/no)? yes
# Warning: Permanently added '[ssh.github.com]:443,[192.30.253.122]:443' (RSA) to the list of known hosts.
# Hi xxx! You've successfully authenticated, but GitHub does not provide shell access.

nvm 系列安装

github.com/lukechilds/…

github.com/nvm-sh/nvm#…

# 用第二个吧

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash

open ~/.zshrc

# This loads nvm
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

command -v nvm 

nvm install node 
nvm i 6.9.1
nvm i stable
nvm run node --version

# To set a default Node version to be used in any new shell, use the alias 'default
nvm alias default node

nrm

github.com/Pana/nrm

npm install -g nrm

cnpm

安装了nrm可以不用安装cnpm

sudo npm install -g cnpm --registry=https://registry.npm.taobao.org

定制terminal皮肤

安装zsh

www.jianshu.com/p/643442297…

github.com/dannynimmo/…

learnku.com/articles/22…

brew install zsh

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

# http://mimosa-pudica.net/src/incr-0.2.zsh 自动补全


git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

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

# 文件地址 /Users/lk-mbp/.oh-my-zsh
# 插件放入 plugins
# 自定义 同级 custom/plugins/incr
# 下载 incr 自动补全插件 http://mimosa-pudica.net/src/incr-0.2.zs
# 主题放入 themes 直接用名字就好


贴一份 ~/.zshrc 配置以免忘记


# 关闭自动更新 Updating Homebrew
export HOMEBREW_NO_AUTO_UPDATE=true

# This loads nvm bash_completion
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" 



# zsh theme

export ZSH=/Users/lk-mbp/.oh-my-zsh

# theme name
ZSH_THEME="punctual"
# ZSH_THEME="robbyrussell"


source $ZSH/oh-my-zsh.sh
source $ZSH/custom/plugins/incr/incr*.zsh
source $ZSH/custom/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
source $ZSH/custom/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

# Hiding parts
# Set any of the following variables to "false" to hide the output.

PUNCTUAL_SHOW_TIMESTAMP="true";		# 时间戳信息
PUNCTUAL_SHOW_USER="false";		# 
PUNCTUAL_SHOW_HOSTNAME="true";
PUNCTUAL_SHOW_CURRENT_DIR="true";	# 文件位置
PUNCTUAL_SHOW_GIT="true";		# git控件

# Colours
# Set any of the following variables to one of the 8 ANSI colour names.

PUNCTUAL_TIMESTAMP_COLOUR="red";
PUNCTUAL_USER_COLOUR="green";
PUNCTUAL_ROOT_USER_COLOUR="yellow";
PUNCTUAL_HOSTNAME_COLOUR="blue";
PUNCTUAL_CURRENT_DIR_COLOUR="magenta";
PUNCTUAL_GIT_COLOUR="cyan";

# Bold fonts
# Set any of the following variables to "true" to use the terminal's bold font.

# PUNCTUAL_TIMESTAMP_BOLD="true";
# PUNCTUAL_USER_BOLD="true";
# PUNCTUAL_ROOT_USER_BOLD="true";
# PUNCTUAL_HOSTNAME_BOLD="true";
# PUNCTUAL_CURRENT_DIR_BOLD="true";
# PUNCTUAL_GIT_BOLD="true";

# Timestamp format
# Set the below variable to customise the timestamp format. See man strftime for format options.

# PUNCTUAL_TIMESTAMP_FORMAT="%l:%M%P";

# Git status symbols
# If you already have your ZSH_THEME_GIT_PROMPT_* variables set, Punctual will respect those. Alternatively, set the following variables to customise the Git status symbols.

PUNCTUAL_GIT_SYMBOL_UNTRACKED="?";
PUNCTUAL_GIT_SYMBOL_ADDED="+";
PUNCTUAL_GIT_SYMBOL_MODIFIED="!";
PUNCTUAL_GIT_SYMBOL_RENAMED="!";
PUNCTUAL_GIT_SYMBOL_DELETED="!";
PUNCTUAL_GIT_SYMBOL_STASHED="*";
PUNCTUAL_GIT_SYMBOL_UNMERGED="M";
PUNCTUAL_GIT_SYMBOL_AHEAD="↑";
PUNCTUAL_GIT_SYMBOL_BEHIND="↓";
PUNCTUAL_GIT_SYMBOL_DIVERGED="~";

PUNCTUAL_PROMPT="$";


plugins=(
	git
	incr # 自动补全功能
	zsh-autosuggestions
	zsh-syntax-highlighting
)