致访客
感谢各位一年多的陪伴,因内容调整,本站将于近日迁移到新域名并不再更新主要内容。

MENU

Mac terminal beautification, auto-completion, syntax highlighting

• March 2, 2022 • π

致访客
感谢各位一年多的陪伴,因内容调整,本站将于近日迁移到新域名并不再更新主要内容。
特此通知。

The default page when the Mac starts up:
截屏2022-03-02 09.35.47.png
We configure and beautify the terminal.

First look at our terminal:

dscl . -read /Users/$USER UserShell

If the above content is displayed, it means that the default terminal of the computer is zsh, and no further processing is required. If not, you need to execute the following command

chsh -s /bin/zsh
To install Oh My Zsh
execute the following command:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
But in most cases our network will prompt that it cannot be accessed.
Here I put the file (install.sh) on the network disk. After downloading, first execute the following command: (mine is on the desktop)

chmod 777 ./Desktop/install.sh
Grant permissions;
then execute the script:

./Desktop/install.sh
If the following page appears, the installation is successful

截屏2022-03-02 09.37.00.png

If the terminal shows this prompt: Insecure completion-dependent directories detected:

截屏2022-03-02 09.37.18.png

Need to do something about it:
vim ~/.zshrc
Enter i to enter edit mode and add at the top of the file

ZSH_DISABLE_COMPFIX=true
Press ESC to exit edit mode, enter

:wq
Save and exit;
enter:

source ~/.zshrc
Update changes. At this time, close the terminal and reopen it, and there is no such prompt.

Modify colors, fonts, etc.
on the terminal Open the preferences of the terminal, select the description file, and set your favorite colors, themes, fonts, and font sizes.

Highlight plugin
download
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
Modify zsh configuration

vim .zshrc
Find the line plugins=(git) and make the following modifications

plugins=(git zsh-syntax-highlighting)
After saving and exiting, enter

source ~/.zshrc
Update changes.

autocompletion plugin
download
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
Modify zsh configuration

vim .zshrc
Find the line plugins=(git zsh-syntax-highlighting) and make the following modifications

plugins=(git zsh-syntax-highlighting zsh-autosuggestions)
After saving and exiting, enter

source ~/.zshrc
Update changes.
At this point, our modification is complete.