homebrew
参考:https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/
安装需求
对于 macOS 用户,系统自带 bash、git 和 curl,在命令行输入 xcode-select --install
安装 CLT for Xcode 即可。
对于 Linux 用户,系统自带 bash,仅需额外安装 git 和 curl。
安装
1.安装 Homebrew / Linuxbrew:
- 从 tsinghua 像下载安装脚本并安装
1
2
3
git clone --depth=1 https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/install.git brew-install
/bin/bash brew-install/install.sh
rm -rf brew-install # 删掉多余的安装包
- 从 GitHub 获取官方安装脚本安装
1
/bin/bash -c "$(curl -fsSL https://github.com/Homebrew/install/raw/master/install.sh)"
2.加入环境变量
- macOS
1
2
3
4
5
#以下针对基于 Apple Silicon CPU 设备上的 macOS 系统(命令行运行 uname -m 应输出 arm64)上的 Homebrew:
test -r ~/.bash_profile && echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.bash_profile
test -r ~/.zprofile && echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
#对基于 Intel CPU 设备上的 macOS 系统(命令行运行 uname -m 应输出 x86_64)的用户可跳过本步。
- linux
1
2
3
4
5
6
#以下针对 Linux 系统上的 Linuxbrew:
test -d ~/.linuxbrew && eval "$(~/.linuxbrew/bin/brew shellenv)"
test -d /home/linuxbrew/.linuxbrew && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
test -r ~/.bash_profile && echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> ~/.bash_profile
test -r ~/.profile && echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> ~/.profile
test -r ~/.zprofile && echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> ~/.zprofile
3.换源
1
2
3
4
5
6
export HOMEBREW_INSTALL_FROM_API=1
export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
brew update
4.使用
配置好后再使用 brew install
安装软件
1
2
brew cask install google-chrome
brew install miniconda
on my zsh
安装zsh brew install zsh zsh-completions
切换到zsh [sudo] chsh -s $(which zsh)
安装oh-my-zsh
1
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
修改主题,在 ~/.zshrc
里的 设置ZSH_THEME="ys"
安装插件 常用autojump、zsh-autosuggestions、zsh-syntax-highlighting三个插件
1
2
3
4
cd ~/.oh-my-zsh/plugins
brew install autojump
git clone git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
git clone https://github.com/zsh-users/zsh-autosuggestions.git
然后在 ~/.zshrc
找到 plugins=
添加下面的,最后保存执行 source ~/.zshrc
1
2
3
4
5
plugins=(
autojump
git zsh-autosuggestions
git zsh-syntax-highlighting
)
fzf
用来增强搜索 ctrl + r
/ command + r
1
2
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install
neovim
1.配置vim vim ~/.vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
set wildmenu"按TAB键时命令行自动补齐"
set ignorecase"忽略大小写"
set number "显示行号"
set ruler"显示当前光标位置"
set autoread"文件在Vim之外修改过,自动重新读入"
set autowrite"设置自动保存内容"
set autochdir"当前目录随着被编辑文件的改变而改变"
set cindent "c/c++自动缩进"
set smartindent
set autoindent"参考上一行的缩进方式进行自动缩进"
set softtabstop=4 "4 character as a tab"
set shiftwidth=4
set smarttab
set hlsearch "开启搜索结果的高亮显示"
set incsearch "边输入边搜索(实时搜索)"
2.切换到neovim
1
brew install neovim
再创建配置文件,复制 ~/.vimrc
的配置
1
2
3
4
mkdir ~/.config/nvim
touch ~/.config/nvim/init.vim
cp ~/.vimrc ~/.config/nvim/init.vim
然后修改 ~/.zshrc
或 ./bashrc
1
2
alias vim="nvim"
alias vi="nvim"
conda
- 换源
vim ~/.condarc
1
2
3
4
5
6
7
show_channel_urls: true
channels:
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- defaults
auto_activate_base: false
- 使用
1
2
3
4
5
6
7
8
9
10
11
12
13
14
conda create -n B --clone A #克隆环境A来创建名为B的环境
conda create -n B python=3.10
conda activate xxxx #开启xxxx环境
conda deactivate #关闭环境
conda info -e #显示所有的虚拟环境
conda remove -n xxxx --all #删除已创建的xxxx虚拟环境
conda update --all
conda clean -p #删除没有用的包
conda clean -t #tar打包
conda clean -a
conda config --show #查看全部配置