preface

  • Recently, I don’t know what happened to the MAC, but I think it is the new product coming, fruit decided to solve the old model’s too smooth bug, there are various problems, such as the bottom of the screen will suddenly burst, about 0.1s at a time, or the interface is stuck and so on. And then you plug in the docking dock and you get zero Internet speed. So take advantage of the Mid-Autumn festival, reinstall, and these bugs are gone. Write down this configuration, save trouble later.
  • Updated the VIM configuration
  • Update the configuration under BIG SUR. Because Apple gave me a new keyboard and battery and a new system, it worked really well. This is also an important reason to update this article. For the Big Sur experience, see the previous post.
  • Recently I found that someone stole my article, do not speak martial virtue.

homebrew

When it comes to Homebrew, there’s Google: 90% of our engineers use the software you wrote (Homebrew), but you can’t flip a binary tree on a whiteboard during an interview, which sucks.

Before downloading and installing, open ~/.zshrc and write proxy Settings, otherwise download will be very slow, write source.

Export http_proxy = http://127.0.0.1:1087 export https_proxy = $http_proxyCopy the code

And then curl it up

curl -i https://google.com
Copy the code

Installation is simple:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Copy the code

Turning off automatic updates is really annoying. Write to ~/.zshrc and source:

export HOMEBREW_NO_AUTO_UPDATE=true
Copy the code

iTerm2

You can download Iterm2 from the website or use Homebrew:

brew cask install iterm2
Copy the code

Then you’ll find a very, very plain terminal, basically the same terminal that comes with the MAC, without further ado:

Next, you’ll work with me to turn it into a cold end of good service.


oh-my-zsh

Instruction installation:

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

Then I switched from bash to ZSH, and after I had installed it, it switched automatically:

chsh -s /bin/zsh
Copy the code


The color

ITerm2 comes with some color schemes, but that’s certainly not enough.

mkdir ~/iterm2 ; cd ~/iterm2
git clone https://github.com/mbadolato/iTerm2-Color-Schemes
Copy the code

Create a directory, call it whatever you want, and download the package. Then use Command + to open configuration and import the colors you just downloaded:

And then you get a lot of happiness:

You can then use the mv iterm2. iterm2 command to hide the folder, or not, depending on your preference.


Frosted glass

Then you can adjust the opacity and blur to get a full frosted glass effect:


The font

Fonts are very, very important. If you think about the bad fonts on Windows, fonts can affect the look and feel of the entire system, even from a software perspective.

Nerd-fonts home page, which also supports ICONS.

brew tap homebrew/cask-fonts
brew cask install font-hack-nerd-font
Copy the code

The newer homebrew:

brew install --cask font-hack-nerd-font
Copy the code

Then check it in the configuration file. Note that the ASCII and non-ASCII ICONS should be the same size.


powerlevel9k

Powerlevel9k is a really cool thing.

git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k
Copy the code

Then open the ZSH configuration file ~/.zshrc and set the theme to:

ZSH_THEME="powerlevel9k/powerlevel9k"
Copy the code

Zshsource ~/.zshrc. Powerlevel9k has a lot of Settings on its own, so I’m going to do a little bit of setup here, so you can set it as you want.

POWERLEVEL9K_MODE="nerdfont-complete"
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(os_icon ssh dir vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs virtualenv)
Copy the code

The first line of my Settings represents using the previous nerd-fonts font

The second line sets the content of the ICONS on the left, including the operating system icon, SSH, directory and Git version management

The third line, to the right, is the return code of the previous command, whether it is root, an indicator of background jobs, and py’s environment.


ZSH plug-in

Not to mention more, syntax highlighting and command hints are definitely needed.

brew install zsh-syntax-highlighting
brew install zsh-autosuggestions
Copy the code

Then fill in the.zshrc with the following:

source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh
Copy the code

Vim setup

Personally, I’m a big fan of Vim, and I try to use it for code editing as long as it’s not too complicated. Let’s take a look at some Settings and configurations. Of course, you can make an IDE directly

Homebrew to install:

brew install vim
Copy the code

I then post the entire vIMRC configuration file first:

Filetype off set RTP +=~/.vim/bundle/ vundle.vim Plugin 'altercation/vim-colors-solarized' Plugin 'tomasr/molokai' Plugin 'vim-scripts/phd' Plugin 'Lokaltog/vim-powerline' Plugin 'octol/vim-cpp-enhanced-highlight' Plugin 'nathanaelkane/vim-indent-guides' Plugin 'derekwyatt/vim-fswitch' Plugin 'kshenoy/vim-signature' Plugin 'vim-scripts/BOOKMARKS--Mark-and-Highlight-Full-Lines' Plugin 'majutsushi/tagbar' Plugin 'vim-scripts/indexer.tar.gz' Plugin 'vim-scripts/DfrankUtil' Plugin 'vim-scripts/vimprj' Plugin 'dyng/ctrlsf.vim' Plugin 'terryma/vim-multiple-cursors' Plugin 'scrooloose/nerdcommenter' Plugin 'vim-scripts/DrawIt' Plugin 'SirVer/ultisnips' Plugin 'derekwyatt/vim-protodef' Plugin 'scrooloose/nerdtree' Plugin 'fholgado/minibufexpl.vim' Plugin 'gcmt/wildfire.vim' Plugin 'sjl/gundo.vim' Plugin 'Lokaltog/vim-easymotion' Plugin 'suan/vim-instant-markdown' Plugin 'lilydjwg/fcitx.vim' "call vund #end() fileType Plugin indent on" Define the shortcut prefix, i.e. <Leader> let mapleader=";" "Set status bar theme style let G :Powerline_colorscheme='solarized256'" Code folding based on indent or syntax set foldMethod =syntax "Turn off folding code set when starting VIm Nofoldenable "open syntax highlighting syntax on" use the colorscheme colorscheme jellybeans "open the filetype detection function filetype on" different file types use different indentation filetype indent On "allows use of plugin fileType Plugin on FileType plugin indent on" Turn off VI mode set NOcp "with MAC sharing clipboard set clipboard+=unnamed" cancel VI compatibility Set nocompatible "Display line number set nu" History command save line number set history=1000 "Automatically read when files are changed externally set autoread" Cancel automatic backup and create SWP file set nobackup Set nowb set noswapFile "Allow positioning with mouse click set mouse= A" Allow region selection SET Selection = EXCLUSIVE "Highlight the line where the cursor is located set cursorLine" Cancel cursor blinking set Novisualbell "always display status line set lastStatus =2" Status bar display current executing command set showcmd" Set ruler "Set command line height to 2 set cmdheight=2" Preserve format when pasting "set paste" Highlight matching brackets set showmatch "Ignore case set when searching Ignorecase "highlight the searched sentence set hlsearch" Set IncSearch "inherits the indentation of the previous line. Set Autoindent" provides automatic indentation for C programs. Set Smartindent "Uses c-style indentation Set softtabStop =4 set Shiftwidth =4 "Allow backspace=eol,start,indent set whichwrap+=<,>,h, L Unwrap set nowrap "display blank space between split Windows set fillchars=vert:\, STL :\, STLNC :\" Keep the cursor 3 lines away from the top and bottom of the buffer set scrolloff=3 "sets the default decoding The set fenc = utf-8 set fencs = utf-8, usc - bom, euc - jp, gb18030, gb2312, GBK, cp936 "set encoding set enc = utf-8 set fileencodings=ucs-bom,utf-8,chinese set langmenu=zh_CN.UTF-8 language message zh_CN.UTF-8 source $VIMRUNTIME/delmenu.vim Source $VIMRUNTIME/menu.vim "automatecomplete fileType plugin indent on set Completeopt =longest,menu wildmenu autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete autocmd FileType python set omnifunc=pythoncomplete#Complete autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS autocmd FileType  html set omnifunc=htmlcomplete#CompleteTags autocmd FileType css set omnifunc=csscomplete#CompleteCSS autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags autocmd FileType java set omnifunc=javacomplete#CompletCopy the code

The color

In fact, iTerm has been matched before, but Vim has its own independent color matching. The usage is also simple: create the.vim/colors directory with the following command, and then download the color matching file:

mkdir -p ~/.vim/colors ; cd ~/.vim/colors
curl -O https://raw.githubusercontent.com/nanotech/jellybeans.vim/master/colors/jellybeans.vim
Copy the code

Open ~/. Vimrc and add ColorScheme Jellybeans, for example, I used this jellybeans. Vim theme. Here’s another gruvbox theme that looks like this:


Code folding,

Use native code for folding

"Code folding based on indentation or syntax "set foldMethod =indent set foldMethod =syntax" Set nofoldenable is turned off when vim is startedCopy the code
  • Enter vim command mode, za can collapse the current block
  • ZM closes all folds
  • ZR opens all folds


Plug-in management and usage

Installation management tool Vundle:

git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
Copy the code

Open.vimrc and add the following plugin content:

"Vundle environment Settings FileType off set RTP +=~/.vim/bundle/ vundle.vim" The list of plug-ins managed by Vundle must be called between vundle#begin() and vundle#end() vundle#begin() Plugin 'VundleVim/Vundle.vim' Plugin 'altercation/vim-colors-solarized' Plugin 'tomasr/molokai' Plugin 'vim-scripts/phd' Plugin 'Lokaltog/vim-powerline' Plugin 'octol/vim-cpp-enhanced-highlight' Plugin 'nathanaelkane/vim-indent-guides' Plugin 'derekwyatt/vim-fswitch' Plugin 'kshenoy/vim-signature' Plugin 'vim-scripts/BOOKMARKS--Mark-and-Highlight-Full-Lines' Plugin 'majutsushi/tagbar' Plugin 'vim-scripts/indexer.tar.gz' Plugin 'vim-scripts/DfrankUtil' Plugin 'vim-scripts/vimprj' Plugin 'dyng/ctrlsf.vim' Plugin 'terryma/vim-multiple-cursors' Plugin 'scrooloose/nerdcommenter' Plugin 'vim-scripts/DrawIt' Plugin 'SirVer/ultisnips' Plugin 'derekwyatt/vim-protodef' Plugin 'scrooloose/nerdtree' Plugin 'fholgado/minibufexpl.vim' Plugin 'gcmt/wildfire.vim' Plugin 'sjl/gundo.vim' Plugin 'Lokaltog/vim-easymotion' Plugin 'suan/vim-instant-markdown' Plugin 'lilydjwg/fcitx.vim' "call vundle#end() filetype plugin indent onCopy the code

Enter vim and type :PluginInstall in command mode to automatically install:

vim-powerline

Use Lokaltog/ VIm-Powerline to set the status bar style:

Let g:Powerline_colorscheme='solarized256'Copy the code

Multiline comment

Multi-line comments are definitely needed. First add buttons, you can add your own handy ones, which I did here; :

"Define the shortcut prefix, i.e. <Leader> let mapleader=";"Copy the code

Then cc comment the selected area, you can use v to select multiple lines. Cu uncomment

Code completion

Vim also has its own code completion, easy to use, CTRL + P can be, and then CTRL + P is up, CTRL + N is down, of course, there are more complex plug-ins to prompt. The end result could be vs level, but I personally don’t think it’s necessary. Please come back and update the content of this article if you need to do so in the future.

Well, actually, there are other buttons, and you can press CTRL + X to display all the hints, and if you look at the bottom line of the picture, you can do CTRL +], CTRL + D and so on.


Python configuration

Modify the PIP source

First change the PIP source:

mkdir .pip ; cd .pip
vim pip.conf
Copy the code

Replace ali source:

[global]
index-url=http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
Copy the code

Or what you like:

  • pypi.douban.com/
  • pypi.hustunique.com/
  • pypi.sdutlinux.org/
  • pypi.mirrors.ustc.edu.cn/

Virtualenv configuration

I’m using VirtualEnv, but it’s ok if you’re in another environment:

pip3 install virtualenv
Copy the code

Use Virtualenv –version to see if the installation is successful.

demo

Create an environment called test_env

virtualenv test_env
Copy the code

And then activate the environment

cd test_env; source ./bin/activate
Copy the code

View the library and exit

pip list; deactivate
Copy the code


Virtualenvwrapper use

Virtaulenvwrapper is a wrapper around virtualEnv to make it easier to manage virtual environments:

You can skip this step as virtualenvWrapper installation seems to be having trouble lately.

pip3 install virtualenvwrapper
Copy the code

Create an environment directory, for example mkdir ~/pyEnv, open the.zshrc file and type the following:

export WORKON_HOME=~/pyEnv
source /usr/local/bin/virtualenvwrapper.sh
Copy the code

Source ~/.zshrc Updates the configuration file, which looks like the following:

Then you can have fun setting up the environment:

  • To create an environment: mkvirtualenv env1
  • Delete the environment: rmVirtualenv env1
  • Switch to another environment: workon env2
  • Exit the environment: deactivate
  • List all environments: lsVirtualenv -b
  • Check the wheels in the environment: lsSitepackages