美化ubuntu终端,建立开发环境

893 阅读1分钟

换源

  1. 备份
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
  1. 更改权限
sudo chmod 777 -R /etc/apt/sources.list
  1. 更改源
sudo vim /etc/apt/sources.list

vim:esc dG删除所有

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
  1. 更新源
sudo apt update

安装并配置zsh、oh-my-zsh、git、starship

  1. 安装并启用zsh
sudo apt install zsh
sudo chsh -s /bin/zsh
  1. 安装oh-my-zsh
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"  

如果出现443的问题(常见)

  1. 改hosts(推荐SwitchHosts)
  2. 走代理
# ~/.zshrc
# 设置代理别名,需要走代理直接setproxy
alias setproxy="export > > ALL_PROXY=socks5://127.0.0.1:10808"
alias unsetproxy="unset ALL_PROXY"
  1. 安装git
sudo apt install git
  1. 安装starship
curl -fsSL https://starship.rs/install.sh | bash
  1. 安装zsh插件
cd ~/.oh-my-zsh/plugins
  • zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
  • zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
  1. 配置starship、zsh插件
sudo vim ~/.zshrc
# ~/.zshrc
eval "$(starship init zsh)"

# 设置代理
alias setproxy="export ALL_PROXY=socks5://127.0.0.1:10808"
alias unsetproxy="unset ALL_PROXY"

export ZSH="/home/zao/.oh-my-zsh"
ZSH_THEME="robbyrussell"

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

source $ZSH/oh-my-zsh.sh
  1. 更新zsh配置
source ~/.zshrc

安装nvm、node、yrm

  1. 安装nvm
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
source ~/.zshrc
  1. 安装node
nvm install node
  1. 安装yrm
npm install -g yrm
yrm use taobao

注意

  1. wsl2适合用remote方式开发,不过在安装vscode插件的时候会有安装不上的情况,这个目前我找到的解决方法是改google ones的DNS;如果直接用local打开,更改文件,不会实时刷新。
  2. wsl1较为轻量不能直接用docker,需要安装docekr desktop
  3. 用wsl开发,如果git安装在wsl中,需要配置vscode的git.path,具体请参照https://github.com/andy-5/wslgit