Thoughts on iTerm2 beautification and garbled code issues

1. iTerm2 beautification

1.1 Environmental requirements

  • iTerm2The biggest requirement for the environment is actually PowerLinethe requirement for fonts
  • This body comes fromNERD FONTS

NERD FONTSProvides a variety of programmer fonts and iconssupplements the system
Insert image description here

1.2 About font selection

  • Regarding this problem, previous tutorials told everyone to download and install the "xxx" font. In fact, it depends on personal preference. You can choose to download and install the font in the tutorial, or you can choose your favorite font (as long as it is a font nerd fontsof to achieve the corresponding effect), you can also download only nerd fontsthe icons in

  • Here is a list of commonly used fonts for you

  • FiraMono Nerd Font
  • Hac Nerd Font( SpaceVimfavorite font)
  • MesloLG Nerd Font(many subjects like Power Level 10Kfavorite fonts)

Insert image description here
Insert image description here
Insert image description here

1.3 Font installation

  • Use HomeBrewto install fonts. HomeBrewI won’t go into details here. MacPeople who use them should have heard of it.
  • Unlike most other tutorials, this article uses two fonts to achieve the purpose of Terminalseparate fonts and iconsseparate management, so that future modifications of the fonts will not affect iconsthe purpose.
  • JetBrainsMono Nerd Font(Used to provide support for fonts, it’s all a matter of personal preference)
  • Symbols Nerd Font(For management to iconsprovide support)

Insert image description here
Insert image description here

  • There are two installation methods:
  • HomeBrew(method used in this article)
  • Local installation
  • <FONT NAME>: actually refers to the content in the red box in the picture above. The actual content depends on the font.
  • <FONT_PATH>: refers to the font path of NERD FONTSthe project ongithub
  • HomeBrewWay
brew tap homebrew/cask-fonts && brew install --cask font-<FONT NAME>-nerd-font
  • Local installation method
curl -fLo "<FONT NAME> Nerd Font Complete.otf" \
https://github.com/ryanoasis/nerd-fonts/raw/HEAD/patched-fonts/<FONT_PATH>/complete/<FONT_NAME>%20Nerd%20Font%20Complete.otf
./install.sh <FontName>

1.4 Oh My Zsh installation

  • Oh My ZshIt is a powerful set of terminal configuration files. This article will not discuss it too much and only shows its beautification functions.
  • will be zshset as default terminal
chsh -s /bin/zsh
  • InstallOh My Zsh

There are two installation methods, one is curlmethod and the other is wgetmethod

  • curlWay
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
  • wgetWay
sh -c "$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
  • oh my zshCatalog and functions
  • oh my zsh.oh-my-zshAfter installation, a hidden folder named " will be created in the root directory to store the party oh my zsh's default configuration files and third-party configuration files.
  • User configuration files are mainly placed customin folders
cd ~/.oh-my-zsh/
tree
.oh-my-zsh文件
├───plugins       # 自带插件目录,每个插件目录下都有一个 README,有详细使用说明
├───themes        # 自带主题目录
└───custom        # 用户自定义目录
    ├───plugins   # 第三方插件目录
    └───themes    # 第三方主题目录

1.6 Install Powerlevel10k theme

  • will be powerlevel10kinstalled ~/.oh-my-zsh/custom/themesinto
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
  • Modified zshconfiguration files, settingsZSH_THEME="powerlevel10k/powerlevel10k
cd 
vim .zshrc
  • set upiTerm2
    Insert image description here
  • Test whether the font is successful and enter iTerm2useget_icon_names
    iTerm+ohmyzsh+powerlevel10k instantly makes your terminal cool
  • Set up powerlevel10security reminders step by step
p10k configure

Insert image description here

2. About iTerm2 garbled characters and others

2.1 Garbled characters caused by fonts

This problem usually occurs at the beginning, that is, after the oh my zshinstallation the theme is modified to the built-in one angoster( ZSH_THEME="agnoster" ). The system lacks the corresponding powerlinefonts, which causes this problem. It can be solved by installing any NERD FONTSfont.

2.2 Garbled icons caused by iTterm2 Arramgements configuration

Almost no one mentions the chaos caused by iTerm2configuration. This is because the conditions for the occurrence of this problem are quite accidental and harsh. My personal guess is that the reason may be that a snapshot Arrangementsequivalent to a certain period is set iTerm2, and its past configuration is saved. Since it is set to "start at boot", the current iTerm2configuration is overwritten with the past configuration every time.

  • When you start using it, it will only be used iTerm2as a built-in . Use all default settings and configure them Terminalafter using it for a period of time.Arrangements
    Insert image description here
    Insert image description here
  • Later, we started to iTerm2beautify the , and iconsgarbled characters began to appear at this time, and NERD FONTSthis problem could not be solved through installation.
  • It is very simple to solve this problem, just delete the original one and Arrangementsreconfigure it.
    Insert image description here

2.3 Others

  • oh my zshA blue triangle appears after upgrading

Cancel show mark indicatorsit


Insert image description here

  • Background settings
    Insert image description here

references

  1. Detailed introduction to Mac iTerm2 configuration tutorial
  2. Mac item2 set window size
  3. Build a better-use Mac - Terminal
  4. iTerm+ohmyzsh+powerlevel10k instantly makes your terminal cool
  5. Knowledge points: iTerm2 + Oh My Zsh usage summary
  6. This iTerm2 + Oh My Zsh tutorial will help you become the most handsome guy on the street step by step.

Guess you like

Origin blog.csdn.net/Y1575071736/article/details/130219284