brew combines iTerm2 fancy fun with terminal commands for MacOS software management

1. Background requirements

  When I just got a new Mac computer for work, many common commands on Linux were not installed. For example, wget,git,telnet……these commands are often used in work. Friends who are familiar with Linux know that there is a powerful yumcommand, so I can use it directly, hehe I found an error, and after stepping on the pit, I found that the command in the original Mac is called brew, and it can also have the following operations;

brew install git
brew install telnet
brew install wget
……
复制代码

  But once you find brewthat you need to install it, a lot of people on the Internet tell you that you can use the following instructions to install it directly;

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
复制代码

  I tried it myself and found that an error was reported curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused, as shown in Figure 1.1;

  The reason is raw.githubusercontent.comthe old beauty. Without jailbreak, it is basically impossible to connect, and it happens to be very slow to connect. How to install it? Reference chapters 2. 安装brew;insert image description here

Figure 1.1 Direct official website download error

2. Install brew

2.1 Download and installation of domestic base stations

  brewThe full name Homebrewis a package management tool under the MacOS platform, which has many practical functions such as installation, uninstallation, update, viewing, and search. With a simple command, you can implement package management without you needing to care about various dependencies and file paths, which is very convenient and fast. A must-have artifact for the terminal, I said the same when Jesus came! The first chapter mentioned that the direct official website cannot be downloaded. Is there any network Lei Feng in China to help solve it? There really is, someone moved it back to the domestic base station and used the following instructions to solve the installation;

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

  During the installation process, you will be asked to select the base station from which to download the mirror image. Generally, you can choose 1it, and for some options Y/N, just follow the prompts to fill Yin it, and the installation is complete until Figure 2.1 appears;insert image description here

Figure 2.1 Prompt for domestic mirror installation

2.2 Activate environment variables

  Activate the environment variable according to the red line in Figure 2.1, that is, run the following statement;    pay attention rowyetto the blogger's account, everyone's is different, do not copy; pay attention rowyetto the blogger's account, everyone's is different, do not copy; Note rowyetFor the blogger's account, everyone's is different, don't copy it; it's three times, try your best;

source /Users/rowyet/.zprofile
复制代码

2.3 Test brew

  Use the following command to do a test. If no error is reported, in principle, brew is installed.

# 更新brew
brew upgrade   

# 安装cask
brew install cask

# 安装 wget
brew install wget

# 安装 git
brew install git

# 安装telnet
brew install telnet
复制代码

3. Install iTerm2

  MacOSThe built-in terminal attaches great importance to the lack of charm, and the appearance cannot be edited. After tossing and turning around in MacOS, FinalShell,JetBrainsafter getting used to it, I finally decided to choose iTerm2it. It iTerm2is the MacOSbest terminal, I said!

  • Official website: iterm2.com/
  • Official website download: You can also download it directly from the official website. The download is a tarball, which can be used after decompression, but we brewwill not download it from the official website if we have it, and use the brew command to download it.

insert image description here

Figure 3.1 Official website download

brewDownload and install   directly iTerm2;

brew install iterm2
复制代码

  After the installation is complete, find the chart in Figure 3.2 on the launchpad;insert image description here

Figure 3.2 iTerm2 installation completed

4. Install oh-my-zsh

  Why oh-my-zsh? It's simple: smarter shellautocompletion, command option hints, richer themes. So that your terminal is not singled out, you can pretend to be a god at first sight. After configuration, as shown in Figure 4.1.insert image description here

Figure 4.1 oh-my-zsh configuration effect

  The installation and configuration steps are as follows;

# 先查看自己iterm2使用的是否是zsh,利用echo $SHELL ,返回/bin/zsh则是
echo $SHELL

/bin/zsh # 返回值

# 如果不是,则执行以下指令
chsh -s /bin/zsh

# 再执行echo $SHELL验证

# 没问题后用cat /etc/shells  确认下/bin/zsh为该系统内的有效sh
cat /etc/shells                                                         1 ↵
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

# 返回值
/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh

# 下载安装git和wget,已安装的略过
brew install wget
brew install git

# 找一个空文件夹
cd /Applications/tools/
mkdir zsh
cd zsh

# 利用wget下载oh my zsh安装包:
wget https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh

#  或者利用git下载oh my zsh安装包,二选一,不要重复操作
git clone https://gitee.com/mirrors/oh-my-zsh.git

# ls观察下自己下载的文件是一个install.sh
chmod 755 install.sh

# 安装
sh install.sh

复制代码

  After the installation is completed, as shown in Figure 4.2;insert image description here

Figure 4.2 oh-my-zsh installation completed

5. Configure environment variables

  Enter the following command to modify the environment variable

cat <<EOF>>~/.zshrc
export ZSH="/Users/lpc/.oh-my-zsh"
DEFAULT_USER="$USER"
ZSH_THEME="bira"
source $ZSH/oh-my-zsh.sh
EOF
复制代码

  The theme is bira, and the blogger thinks it looks the best. If you need to change the theme, you can directly modify ~/.zshrcthe bira in ZSH_THEME="bira" in the file. For more topics, please refer to: github.com/ohmyzsh/ohm… , refresh environment variables after configuration;

# 刷新环境变量
source ~/.zshrc
复制代码

  You can get the change in Figure 5.1;insert image description here

Figure 5.1 oh-my-zsh style change

6. Install the plugin

   Install some interesting plugins, as follows

# 先安装一个必要的工具箱
xcode-select --install

# 修正错误,经典的遇到错误 fuck一下来了
brew install thefuck

# 命令输入提示
brew install zsh-autosuggestions

# 命令行高亮显示
brew install zsh-syntax-highlighting

# 文件夹跳转
brew install autojump

复制代码

   After installation, you need to configure the environment variables vim ~/.zshrc;

……省略……
# 滑到最下面,修改以下内容,注意rowyet的地方是博主的账号,不要照抄
# 滑到最下面,修改以下内容,注意rowyet的地方是博主的账号,不要照抄
# 滑到最下面,修改以下内容,注意rowyet的地方是博主的账号,不要照抄

export ZSH="/Users/rowyet/.oh-my-zsh"
DEFAULT_USER="rowyet"
ZSH_THEME="bira"
plugins=(
  git
  pip
  zsh-autosuggestions
  zsh-syntax-highlighting
  autojump
)

source /Users/rowyet/.oh-my-zsh/oh-my-zsh.sh

export HOMEBREW_NO_AUTO_UPDATE=true
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles

source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
export ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR=/usr/local/share/zsh-syntax-highlighting/highlighters


eval $(thefuck --alias)

# 最后wq!保存退出

复制代码

   source .zshrcRefresh the environment variables, an error may be reported, use the following commands to fix it;

source .zshrc
[oh-my-zsh] plugin 'zsh-autosuggestions' not found
[oh-my-zsh] plugin 'zsh-syntax-highlighting' not found

# 修复 plugin 'zsh-autosuggestions' not found
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions

# 修复 plugin 'zsh-syntax-highlighting' not found
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting
复制代码

7. Use of the fuck command

  1. Try to input first brew sear www.baidu.com, the result is an error;
  2. Then you enter fuck;
  3. She returns you a relatively correct grammar, then you press the enterkey to execute the command, and press ctrl+cto terminate the command, smart, fun, right?

Note: Fucking is fun, but it is not necessarily accurate. Don't mess with it. You still have to look at the instruction code yourself. Although the wine is good, don't be greedy!

insert image description here

Figure 7.1 Use of the fuck instruction

8. Modify iTerm2 background board

   Many people must think how to change the background of iTerm2 嵩嵩, can I replace it with a photo of a teacher? Hey, of course, the operation is shown in Figure 8.1;

  1. Click on the top menu bar ITerm2, select Preferences…:;
  2. Jump out of the new pop-up box, select Profiles, and then select the menu bar on the right Window;
  3. Click the red box to replace the picture you prepared in advance, then the blogger has chosen a favorite of his wife 嵩嵩, and Blendingyou can adjust the transparency of the picture;
  4. There are also more operations to adjust the appearance of iTerm2, such as fonts, colors, and more.

insert image description here

Figure 8.1 Change iTerm2 background

  Conclusion: brewCombined with the terminal commands managed by the iTerm2fancy fun MacOSsoftware, more interesting plug-ins and knowledge are waiting for everyone to explore together.

Guess you like

Origin juejin.im/post/7083320004430528526