mac & linux 安装oh my zsh 并配置vim和环境变量

一、安装oh my zsh

1、先执行安装命令

mac 安装 zsh 命令

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
export PATH=$PATH:/opt/homebrew/bin

brew install zsh 

linux 安装  zsh 命令

sudo apt-get install zsh

2、安装、切换 oh my zsh

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

3、安装oh my zsh 插件

cd ~/.oh-my-zsh/plugins/
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM}/plugins/zsh-completions
git clone https://github.com/zsh-users/zsh-syntax-highlighting $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-history-substring-search $ZSH_CUSTOM/plugins/zsh-history-substring-search
git clone https://github.com/zsh-users/web-search $ZSH_CUSTOM/plugins/web-search
git clone https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/web-search $ZSH_CUSTOM/plugins/web-search 

4、安装oh my zsh 主题

cd ~/.oh-my-zsh/themes/
git clone https://github.com/zsh-users/robbyrussell
git clone https://github.com/zsh-users/powerlevel10k/powerlevel10k

5、在~/.zshrc配置插件和主题

vim ~/.zshrc

输入以下内容

 1 export ZSH="$HOME/.oh-my-zsh"
 2 
 3 # See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
 4 ZSH_THEME="robbyrussell"
 5 
 6 # ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
 7 
 8 # Uncomment the following line to use case-sensitive completion.
 9 CASE_SENSITIVE="true"
10 
11 # HYPHEN_INSENSITIVE="true"
12 
13 zstyle ':omz:update' mode auto      # update automatically without asking
14 zstyle ':omz:update' frequency 13
15 
16 # Uncomment the following line if pasting URLs and other text is messed up.
17 # DISABLE_MAGIC_FUNCTIONS="true"
18 
19 # Uncomment the following line to disable colors in ls.
20 # DISABLE_LS_COLORS="true"
21 
22 DISABLE_AUTO_TITLE="true"
23 
24 # Uncomment the following line to enable command auto-correction.
25 # ENABLE_CORRECTION="true"
26 
27 COMPLETION_WAITING_DOTS="true"
28 
29 # DISABLE_UNTRACKED_FILES_DIRTY="true"
30 
31 HIST_STAMPS="mm/dd/yyyy"
32 
33 # ZSH_CUSTOM=/path/to/new-custom-folder
34 
35 # plugins=(git)
36 plugins=(
37   git z  extract web-search macos autojump copyfile copypath
38   zsh-history-substring-search
39   zsh-completions
40   zsh-autosuggestions
41 # zsh-syntax-highlighting
42 )
43 
44 source $ZSH/oh-my-zsh.sh
45 
46 # export MANPATH="/usr/local/man:$MANPATH"
47 
48 export LANG=en_US.UTF-8
49 
50 # Preferred editor for local and remote sessions
51 # if [[ -n $SSH_CONNECTION ]]; then
52 #   export EDITOR='vim'
53 # else
54 #   export EDITOR='mvim'
55 # fi
56 
57 # Compilation flags
58 # export ARCHFLAGS="-arch x86_64"
59 
60 # alias zshconfig="mate ~/.zshrc"
61 # alias ohmyzsh="mate ~/.oh-my-zsh"
View Code

 

二、安装基础软件

1、mac安装命令

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

brew install -y jenkins
brew upgrade jenkins

brew install -y qrencode
pip3 install myqr
brew install -y nginx git 

brew install mongodb-atlas

brew install neofetch
brew install chromium xcode
brew install CocoaPods

brew tap dart-lang/dart
brew install dart
brew upgrade dart
brew install dart-lang/dart/dart@2.0
brew install dart@2.12
brew info dart
mkdir -p $HOME/bin/flutter_sdk/
git clone -b master https://github.com/flutter/flutter.git $HOME/bin/flutter_sdk/

2、linux安装命令

sudo apt-get install -y autojump

sudo apt-get install -y openssh-server openssh-client curl jenkins nginx git neofetch zsh 
sudo apt-get install -y python3-pip
pip install pip -U
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
sudo apt-get install -y software-properties-common
#sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update

  

三、在~/.bashrc配置环境变量

1、mac配置bashrc方法

export LS_OPTIONS='--color=auto'
export CLICOLOR='Yes'
export LSCOLORS='CxfxcxdxbxegedabagGxGx'

# git clone https://github.com/pyenv/pyenv.git ~/.pyenv
export PYENV_ROOT=$HOME/.pyenv
export PYENV_PATH=$PYENV_ROOT/bin

export PYTHON2_HOME=/Library/Frameworks/Python.framework/Versions/2.7
export PYTHON3_HOME=/Library/Frameworks/Python.framework/Versions/3.11
export PYTHON_HOME=$PYTHON3_HOME/bin
export PYTHON_PATH=$PYENV_PATH
#export PYTHON_PATH=$PYTHON_HOME
#alias python=/usr/local/bin/python2
#alias python=/usr/local/bin/python3


export JAVA20_HOME=/Library/Java/JavaVirtualMachines/jdk-20.jdk/Contents/Home
export JAVA17_HOME=/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home
export JAVA11_HOME=/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home
export JAVA8_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home
export JAVA_HOME=$JAVA17_HOME
export JAVA_PATH=$JAVA_HOME/bin

export ANDROID_HOME=$HOME/Library/Android/sdk
export ANDROID_PATH=$ANDROID_HOME/build-tools/34.0.0:$ANDROID_HOME/platform-tools
export ANDROID_SDK_ROOT=$ANDROID_HOME

export NDK_HOME=$HOME/bin/ndk/android-ndk-r10
export NDK_PATH=$NDK_HOME

export FLUTTER_ROOT=$HOME/bin/flutter_sdk/flutter_git
#export FLUTTER_ROOT=$HOME/bin/flutter_sdk/flutter2.5.0
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export FLUTTER_PATH=$FLUTTER_ROOT/bin

#export DART_HOME=/opt/homebrew/opt/dart@3.0
#export DART_HOME=$HOME/bin/dart_sdk/dart2.12.0
export DART_HOME=$HOME/bin/dart_sdk/dart2.19.0
export DART_PATH=$DART_HOME/bin

export TOMCAT_HOME=$HOME/bin/tomcat/apache-tomcat-11.0.0-M10
export TOMCAT_PATH=$TOMCAT_HOME/bin

export DIFF_PATH=$HOME/bin/diff 
export VERSION_PATH=$HOME/bin/version
export SQLITE_PATH=$HOME/bin/sqlite 

export ANT_HOME=$HOME/bin/ant/apache-ant-1.10.5
export ANT_PATH=$ANT_HOME/bin

export DEAPK_HOME=~/bin/de_apk
export DEAPK_PATH=~/bin:$DEAPK_HOME:$DE_APK_HOME/apktool:$DE_APK_HOME/dex2jar:$DE_APK_HOME/jd-gui-osx

export JEB_PATH=~/bin/jeb/jeb4.0

export ANDROID_TOOLS_PATH=$HOME/bin/android_tools/uiautomatorviewer 

export MY_PATH=$PYTHON_PATH:$JAVA_PATH:$ANDROID_PATH:$DEAPK_PATH:$JEB_PATH:$NDK_PATH:$FLUTTER_PATH:$DART_PATH:$DIFF_PATH:$VERSION_PATH:$SQLITE_PATH:$ANT_PATH:$ANDROID_TOOLS_PATH:$TOMCAT_PATH

export PATH=$MY_PATH:$PATH:$HOME/bin:/sbin:/usr/bin:/usr/sbin:$HOME/.pub-cache/bin


export CHROME_EXECUTABLE=/opt/homebrew/bin/chromium

export PYTHONHTTPSVERIFY=0

export ANDROID_PRODUCT_OUT=$HOME/mnt/win_vb_ubuntu_aosp/android_13/out

#export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'
# set the number of open files to be 1024
ulimit -S -n 2048

  

四、在~/.vimrc配置vim

mac和widnow、ubuntu配置方法通用

colorscheme desert    " 颜色显示方案
syntax on             " 打开语法高亮
set nu                " 显示行号
set tabstop=4                " 设置tab键的宽度
set shiftwidth=4             " 换行时行间交错使用4个空格
set autoindent               " 自动对齐
set backspace=2              " 设置退格键可用
set shiftwidth=4             " 自动缩进4空格
set smartindent              " 智能自动缩进
set number                   " 在每一行最前面显示行号
set showmatch                " 高亮显示对应的括号
set mouse=a                  " 启用鼠标
set ruler                    " 在编辑过程中,在右下角显示光标位置的状态行
set cursorline               " 突出显示当前行
set noswapfile               " 设置无交换区文件"
set writebackup              " 设置无备份文件
set nobackup                 " 设置无备份文件
set autochdir                " 设定文件浏览器目录为当前目录
set foldmethod=syntax        " 选择代码折叠类型
set laststatus=2             " 开启状态栏信息
set cmdheight=2              " 命令行的高度,默认为1,这里设为2
set autoread                 " 当文件在外部被修改,自动更新该文件
set autoread                 " 自动检测并加载外部对文件的修改
set autowrite                " 自动检测并加载外部对文件的修改
set showcmd                  " 在状态行显示目前所执行的命令,未完成的指令片段亦会显示出来
syntax enable                " 打开语法高亮
 
if has("gui_running")
    set guioptions+=b        " 显示底部滚动条
    set nowrap               " 设置不自动换行
endif
 
" 设置换行编码
set fileformats=unix,dos,mac
" 设置Vim 内部使用的字符编码方式
set encoding=utf-8
" 设置文件编码
if has("win32")
    set fileencoding=chinese
else
    set fileencoding=utf-8
endif
" 解决consle输出乱码
" language messages zh_CN.utf-8

  

五、安装遇到的问题

1、raw.githubusercontent.com 无法访问

sudo vim /etc/hosts

185.199.111.133 raw.githubusercontent.com
20.205.243.166 github.com

或者打开 https://site.ip138.com/raw.githubusercontent.com/ 查看ip。

posted @ 2023-09-08 15:13  狐狸已化妖  阅读(911)  评论(0)    收藏  举报