Original post from my blog

I have an almost idle MBP MID 2015 in my hand. Recently, I upgraded Big Sur, which feels brand-new and I want to use it as the main machine. After all, the hardware configuration is better than the low MBP given by the company. According to the now accustomed development environment, reinstall (next time try to use dotfiles management).

Install the fonts

git clone https://github.com/powerline/fonts.git
cd fonts
./install.sh
Copy the code

Install homebrew

The domestic network environment is too poor, the installation speed is too slow, the agent is still only tens of KB speed, can only choose to change the mirror source.

You must have bash, git, and curl installed, as well as Command Line Tools (CLT) for Xcode, xcode-select –install.

Next, enter the following commands on the terminal to set the environment variables:

BREW_TYPE="homebrew"
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/${BREW_TYPE}-core.git"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/${BREW_TYPE}-bottles"
Copy the code

Finally, run the following command from your terminal to install Homebrew/Linuxbrew:

git clone --depth=1 https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/install.git brew-install
/bin/bash -c "$( cat brew-install/install.sh | sed -E 's|^(\s*HOMEBREW_BREW_GIT_REMOTE=)1 "(. *) $| \${HOMEBREW_BREW_GIT_REMOTE:-\2}"|g' | sed -E 's|^(\s*HOMEBREW_CORE_GIT_REMOTE=)(.*)$|\1"${HOMEBREW_CORE_GIT_REMOTE:-\2}"|g'
)"
rm -rf brew-install
Copy the code

This allows the image to be used during the first installation.

After Homebrew is installed, you need to set up taps and switch sources:

BREW_TAPS="$(brew tap)"
for tap in core cask{,-fonts,-drivers,-versions}; do
    if echo "$BREW_TAPS" | grep -qE "^homebrew/${tap}\ $"; then
        # set the upstream of existing tap to this image and set auto Update
        # Note: The original Auto Update is only valid for upstream hosted on GitHub
        git -C "$(brew --repo homebrew/${tap})" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-${tap}.git
        git -C "$(brew --repo homebrew/${tap})" config homebrew.forceautoupdate true
    else   # Install automatically when tap is missing (delete this line and the following line if not needed)
        brew tap --force-auto-update homebrew/${tap} https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-${tap}.git
    fi
done
Copy the code

Reset the git repository HEAD after changing the upstream:

brew update-reset
Copy the code

If there is a problem, you can restore the upstream of the warehouse:

BREW_TAPS="$(brew tap)"
for tap in core cask{,-fonts,-drivers,-versions}; do
    if echo "$BREW_TAPS" | grep -qE "^homebrew/${tap}\ $"; then
        git -C "$(brew --repo homebrew/${tap})" remote set-url origin https://github.com/Homebrew/homebrew-${tap}.git
    fi
done

Reset git repository HEAD
brew update-reset
Copy the code

Binary pre-compiled bag bottles for source:

# temporary replacement
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/bottles"

# Long term replacement
# bash
echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/bottles"' >> ~/.bash_profile
# zsh
echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/bottles"' >> ~/.zprofile
Copy the code

Install iTerm2

Install with Homebrew:

brew install --cask iterm2
Copy the code

Install theme Nord:

wget https://raw.sevencdn.com/arcticicestudio/nord-iterm2/develop/src/xml/Nord.itermcolors
Copy the code

Preferences → Profiles → Colors → Color preset → Import, select the downloaded theme file.

Set cursor jump, Preferences → Keys → Natural Text Editing.

Oh – my – ZSH installation

Install oh-my-zsh with command completion and highlight:

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

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
Copy the code

Next update vim.zshrc, find plugins=(git) and change it to plugins=(git zsh-autosuggestions zsh-synth-highlighting)

Set the theme:

Clone this repo:

git clone https://github.com/denysdovhan/spaceship-prompt.git "$ZSH_CUSTOM/themes/spaceship-prompt" --depth=1
Copy the code

Symlink spaceship.zsh-theme to your oh-my-zsh custom themes directory:

ln -s "$ZSH_CUSTOM/themes/spaceship-prompt/spaceship.zsh-theme" "$ZSH_CUSTOM/themes/spaceship.zsh-theme" 
Copy the code

Set ZSH_THEME="spaceship" in your .zshrc.

Final style:

Install tmux

Install tmux:

brew install tmux
Copy the code

oh-my-tmux

Select oH-my-TMUx one-click configuration:

cd ~
git clone https://github.com/gpakosz/.tmux.git
ln -s -f .tmux/.tmux.conf
cp .tmux/.tmux.conf.local .


brew install reattach-to-user-namespace
Copy the code

All subsequent TMUx configurations can be modified in.tmux.conf.local.

Nord – tmux subject

Nord is a clean, cool color theme that provides a collection of theme plugins such as JetBrains, VScode, Vim, TMUx, and a full repository of theme plugins.

Search for the plugin location in.tmux.conf.local and add a line below:

set -g @plugin "arcticicestudio/nord-tmux"
Copy the code

End result:

Install multiple JDK versions

Activate the AdoptOpenJDK:

brew tap AdoptOpenJDK/openjdk
Copy the code

Install jdK8 with domestic image, edit rb file, replace downloaded URL:

vim /usr/local/Homebrew/Library/Taps/adoptopenjdk/homebrew-openjdk/Casks/adoptopenjdk8.rb


cask "adoptopenjdk8" do
  version "8282: a b08"
  sha256 "f12d380ceae806d02c4cae23bdc601402c543692c763122286b99d8ef6059794"

  # github.com/AdoptOpenJDK was verified as official when first introduced to the cask
  #url "https://github.com/AdoptOpenJDK/openjdk#{version.before_comma}-binaries/releases/download/jdk8u282-b08/OpenJDK8U-jdk_x6 4_mac_hotspot_8u282b08.pkg",
  url "https://mirrors.tuna.tsinghua.edu.cn/AdoptOpenJDK/8/jdk/x64/mac/OpenJDK8U-jdk_x64_mac_hotspot_8u282b08.pkg".verified: "https://github.com/AdoptOpenJDK"
  appcast "https://github.com/adoptopenjdk/openjdk#{version.before_comma}-binaries/releases/latest"
  name "AdoptOpenJDK 8"
  desc "AdoptOpenJDK OpenJDK (Java) Development Kit"
  homepage "https://adoptopenjdk.net/"

  pkg "OpenJDK8U-jdk_x64_mac_hotspot_8u282b08.pkg"

  postflight do
    system_command "/usr/sbin/pkgutil".args: ["--pkg-info"."net.adoptopenjdk.8.jdk"].print_stdout: true
  end

  uninstall pkgutil: "net.adoptopenjdk.8.jdk"
end
Copy the code

Likewise, jdk11, jdk15 can replace the URL installation:

vim /usr/local/Homebrew/Library/Taps/adoptopenjdk/homebrew-openjdk/Casks/adoptopenjdk11.rb

url "https://mirrors.tuna.tsinghua.edu.cn/AdoptOpenJDK/11/jdk/x64/mac/OpenJDK11U-jdk_x64_mac_hotspot_11.0.10_9.pkg"


vim /usr/local/Homebrew/Library/Taps/adoptopenjdk/homebrew-openjdk/Casks/adoptopenjdk15.rb

url "https://mirrors.tuna.tsinghua.edu.cn/AdoptOpenJDK/15/jdk/x64/mac/OpenJDK15U-jdk_x64_mac_hotspot_15.0.2_7.pkg"
Copy the code

After replacing the URL, execute:

brew install --cask adoptopenjdk8
brew install --cask adoptopenjdk11
brew install --cask adoptopenjdk15
Copy the code

You can use Jenv to manage multiple JDK versions:

brew install jenv
Copy the code

Add jenv environment to.zshrc:

# java env
export PATH="$HOME/.jenv/bin:$PATH"
eval "$(jenv init -)"
Copy the code

To view the installed JDK version and path:

/usr/libexec/java_home -V

Matching Java Virtual Machines (3):
    15.0.2 (x86_64) "AdoptOpenJDK" - "AdoptOpenJDK 15"/ Library/Java/JavaVirtualMachines/adoptopenjdk - 15. JDK/Contents/Home 11.0.10 (x86_64)"AdoptOpenJDK" - "AdoptOpenJDK 11"/ Library/Java/JavaVirtualMachines/adoptopenjdk - 11. The JDK/Contents/Home 1.8.0 comes with _282 (x86_64)"AdoptOpenJDK" - "AdoptOpenJDK 8" /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
Copy the code

Add to Jenv to manage:

jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-15.jdk/Contents/Home
jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
Copy the code

Set the global default JDK version:

Jenv global 1.8Copy the code

Install maven

Homebrew installation:

brew install maven
Copy the code

Setting the environment (generally not required) :

# Query the installation pathMVN - version Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: / usr /local/Cellar/maven/3.6.3 /libexec Java version: 15.0.2, vendor: N/A, Runtime: /usr/local/ Cellar/its / 15.0.2 / libexec/its JDK/Contents/Home Default locale: zh_CN_#Hans, platform encoding: UTF-8
OS name: "mac os x", version: "11.2.3", arch: "x86_64", family: "mac"

Set environment variables
vim ~/.zshrc

export M2_HOME=/usr/local/ Cellar/maven / 3.6.3 _1 / libexecexport M2=$M2_HOME/bin
Copy the code

Install the node

Homebrew install N (Node Version Management) :

brew install n
Copy the code

Download the latest LTS versions of Node and NPM:

n lts
Copy the code

Setting up the NPM image:

vim ~/.zshrc

# node, npm
export NODE_MIRROR=https://npm.taobao.org/dist/
Copy the code

Install python

Homebrew install Anaconda:

brew cask install anaconda
Copy the code

Creating the Python environment

Conda create -n py2 python=2.7 conda create -n py3 python=3.8Copy the code

Install vscode

Jetbrains is great, but my account is out of date, I don’t want to pay, and the company’s computer is a beggar’s VERSION of MBP, so 8GB of memory is too tight. However, the development machine provided by the company has 4 C 16G configuration, and provides a customized VScode Server software package, in the development machine docker start VScode Server, and then local MBP run a matching customized VScode client, It is equivalent to remote coding directly in the development machine. This is the solution of most of my colleagues using c++ development, but it can be used as an alternative to jetbrain idea intellij by referring to the support for Java solution provided by vscode and adding necessary Java, maven, spring and other plug-ins.

At present, I have used VScode as the main development IDE for nearly half a year, and my low-configuration office MBP has rarely made the sound of fans. After getting used to the coding and debug processes of VScode, the efficiency has become much higher, after all, there is no lag any more.

Install vscode:

brew install --cask visual-studio-code
Copy the code

Go to the app marketplace to install plug-ins

Spring Boot Extension Pack Spring Boot Extension PackCopy the code

The alias configuration

git

Git global config:

git config --global -e


[user]
    name = fakeyanss
    email = [email protected]
[core]
    editor = vim
[alias]
    # Shortening aliases
    co = checkout
    cob = checkout -b
    f = fetch -p
    c = commit
    p = push
    ba = branch -a
    bd = branch -d
    bD = branch -D
    dc = diff --cached

    # Feature improving aliases
    st = status -sb
    a = add -p

    # Complex aliases
    plog = log --graph --pretty='format:%C(red)%d%C(reset) %C(yellow)%h%C(reset) %ar %C(green)%aN%C(reset) %s'
    tlog = log --stat --since='1 Day Ago' --graph --pretty=oneline --abbrev-commit --date=relative
    lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
    bdm = ! "" git branch --merged | grep -v '*' | xargs -n 1 git branch -d"
    rank = ! "" git log --format='%aN' | sort -u | while read name; do echo \"\\033[32m$name\\033[0m\t\"; git log --author=\"$name\" --pretty=tformat: --numstat | awk \"{ add += \\The $1; subs += \\$2; loc += \\The $1- \ \$2 } END { printf \\\"added lines: %s, removed lines: %s, total lines: %s\\n\\\", add, subs, loc }\" -; done"
Copy the code

mysql

Install myCLI client

brew install mycli
Copy the code

Configure common connection aliases:

vim ~/.zshrc
alias devdb='mycli -h127.0.0.1 -P3306 -Ddev -udev -pdev'
Copy the code

This article was automatically published by ArtiPub