跳转至

如何快速配置一个开发环境?

安装软件

  1. 安装开发工具
  2. VSCode
  3. Git
  4. WSL
  5. Python


  1. 配置开发工具

  2. 配置软件安装源

  3. 备份默认安装源:sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
  4. 替换默认安装源:sudo vim /etc/apt/sources.list
    deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
    
  5. 更新源:sudo apt-get update
  6. 更新软件:sudo apt-get upgrade

  7. Git

  8. 配置git用户名和邮箱
    git config --global user.name "username"
    git config --global user.email "useremail@test.com"
    
  9. 生成SSH密钥:ssh-keygen -t rsa -C "useremail@test.com"
  10. 拷贝 id_rsa.pub 内容: cat ~/.ssh/id_rsa.pub
  11. 将 id_rsa.pub 内容添加到 GitHub

  12. Python

  13. 安装pip3:

    sudo apt-get install python3-pip
    

  14. 安装虚拟环境:

    sudo apt install virtualenv
    sudo apt install virtualenvwrapper
    

  15. virtualenvwrapper 操作虚拟环境常用命令:

    mkvirtualenv <env_name>
    lsvirtualenv
    workon
    workon <env_name>
    rmvirtualenv <env_name>
    

  16. 终端

  17. 安装终端:

    sudo apt-get install zsh
    sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
    

  18. 安装插件:

    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
    

  19. 配置终端

    export ZSH="$HOME/.oh-my-zsh"
    
    ZSH_THEME="robbyrussell"
    
    plugins=(
            git
            zsh-autosuggestions
            zsh-syntax-highlighting
    )
    
    source $ZSH/oh-my-zsh.sh
    
    
    # Python Virtual Env
    export WORKON_HOME=~/.virtualenvs
    export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
    export VIRTUALENVWRAPPER_VIRTUALENV=/usr/bin/virtualenv
    source /usr/share/virtualenvwrapper/virtualenvwrapper.sh
    
    source $ZSH_CUSTOM/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
    source $ZSH_CUSTOM/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh