当前位置:网站首页>Iterm2 configuration and beautification

Iterm2 configuration and beautification

2020-11-08 20:13:00 anchovies

Because of the new computer , Software and environment need to be reconfigured , It's about iTerm2 The configuration and beautification of finishing an article out , It's convenient for your future work , Also for you to provide some reference , You are welcome to point out the mistakes , If you have a good plug-in or good color, you are welcome to share

Description

install iTerm2

First , download iTerm2 To replace the default terminal .

https://iterm2.com/

What is? iTerm2?

iTerm2 is a replacement for Terminal and the successor to iTerm. It works on Macs with macOS 10.12 or newer. iTerm2 brings the terminal into the modern age with features you never knew you always wanted.

iTerm2 It's a replacement for the default terminal , Also present Mac The best terminal tool under the system , It's a combination of beauty and efficiency .

The migration configuration ( Optional )

Because I used to be Mac platform , So there are some configurations that you can use in the ITerm From inside out , In fact, reconfiguration is the same , No impact .

On the original computer iterm Export configuration : Description

Export configuration

Description

Then import it into your new computer : Description Pictured above import JSON Profiles, Then set it to the default configuration .

Import and use

adjustment Status Bar

take iTerm2 Bring their own theme It is amended as follows Minimal ( Preferences-Appearance-General-Theme ) To achieve the immersive effect of the top bar

Can be in Profiles tab ,Session At the bottom of the page, you can see the opening options .Status bar enabled Options , Check to open . Click... On the right Configure Status Bar Button to set the display content .

You can see that there is a lot to show , Drag the content to be displayed above to the bottom Active Components Areas are added .

stay Preference Click in the page Appearance tab , You can set Status bar The location of , modify Status bar location, I'll change it to Bottom Bottom .

Description

Set location Status bar effect : Description

The content displayed can also be adjusted by itself :

Status bar Adjust the

Change color matching ( Optional )

I prefer Dracula The color scheme , Include VS Code It's all about this color scheme .

https://draculatheme.com/iterm/

Decompress and replace Preferences-Profiles-Color-Color Presets-Import

Set up zsh The theme

Configure theme :

It just needs to be modified .zshrc In the document ZSH_THEME="xx" Attribute is enough .

The theme I'm using right now is :spaceship

according to github The method configuration in the project description is enough , Or refer to the topic configuration below

Premise :

Installed zsh Installed powerline typeface Installation method reference :https://github.com/powerline/fonts

And then put iTerm The font of is set to powerline, Include Font and Non-ASCII Font

Set the font

Download the theme file :

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

Create a soft connection

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

modify zsh To configure

vim ~/.zshrc

modify :

ZSH_THEME="spaceship"

take effect :

source ~/.zshrc

Then there are some configuration of the theme , Refer to this file for configuration instructions :

https://github.com/denysdovhan/spaceship-prompt/blob/master/docs/Options.md

Specific configuration shows what content , According to the document in ./zshrc Just add it in . Here's my configuration :

PS: Color values refer to this https://upload.wikimedia.org/wikipedia/commons/1/15/Xterm_256color_chart.svg

My configuration

Set the display time

SPACESHIP_TIME_SHOW="true"

Set display user name , And change the color of the user name to macho pink

SPACESHIP_USER_SHOW="always"

SPACESHIP_USER_COLOR="212"

The subject corresponds to the address :

https://github.com/denysdovhan/spaceship-prompt

Set up Oh-My-Zsh

What is? Oh-My-Zsh?

Oh My Zsh Is a community driven command line tool , It's based on zsh Command line , Provides theme configuration , Plug-in mechanism , Greatly improved playability ( use ) sex . Improving efficiency can also make people happy hhh

Website :https://ohmyz.sh/

Enter the following command :

curl The way

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

Or use wget:

sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

To configure Oh-My-Zsh Configuration command auto prompt About the configuration of plug-ins , If you want to see which plug-ins are currently installed , Can be in .zshrc Mid search plugins keyword , Get the following , It's also the configuration content in my old computer :

plugins=(
  git
  autojump
  zsh-autosuggestion
  zsh-syntax-highlighting
)

About command prompts

When we type commands , The terminal will automatically prompt you for the following commands that you may enter , Now press → You can output these commands , Very convenient .

The effect can be referred to GitHub Video in project description

Project address :https://github.com/zsh-users/zsh-autosuggestions

  • 1、 Clone the project locally $ZSH_CUSTOM/plugins Under the path ` The default is ·~/.oh-my-zsh/custom/plugins

    git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

  • 2、 edit ~/.zshrc The configuration file , Add to plugins In the list

    plugins=(zsh-autosuggestion)

  • 3、 Open a new terminal window to view the effect

Automatic prompt

If you don't see the effect of the prompt in the end, it may be a color configuration problem , Reference resources GitHub The modification method in the project description is used to modify the configuration

Configure syntax highlighting Project address :https://github.com/zsh-users/zsh-syntax-highlighting

Installation method :

Recommended HomeBrew Installation :

  • 1、brew install
brew install zsh-syntax-highlighting
brew Project address of  https://brew.sh/
  • 2、 stay ~/.zshrc The tail , Insert a row :

    source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

vim in Use it directly shift+g The last line you can jump to

  • 3、 Effective configuration

    source ~/.zshrc

To configure autojump

effect : Realize fast directory jump , Which directory do you want to go to directly j + Directory name ( You don't even have to lose everything ), Don't use frequent cd 了 Project address :https://github.com/wting/autojump

Installation method :

  • 1、brew install

    brew install autojump
    
  • 2、 modify ~/.zshrc file , Add to plugins Configure the list and append the following to the end :

    [ -f /usr/local/etc/profile.d/autojump.sh ] && . /usr/local/etc/profile.d/autojump.sh
    

    plugins Don't forget to add autojump:

    plugins=(
       git
       zsh-autosuggestion
      autojump
    )
    

    then source Make him effective

PS: stay brew There will be a prompt output after installation , Follow the prompts to configure :

Add the following line to your ~/.bash_profile or ~/.zshrc file (and remember
to source the file to update your current session):
  [ -f /usr/local/etc/profile.d/autojump.sh ] && . /usr/local/etc/profile.d/autojump.sh

If you use the Fish shell then add the following line to your ~/.config/fish/config.fish:
  [ -f /usr/local/share/autojump/autojump.fish ]; and source /usr/local/share/autojump/autojump.fish

zsh completions have been installed to:
  /usr/local/share/zsh/site-functions

summary

This is my favorite color matching and beautification scheme at present , There are also some holes in the configuration process , There are some problems , It is concluded in this article , Of course , Colors and plugins have their own preferences , Welcome to leave a message

版权声明
本文为[anchovies]所创,转载请带上原文链接,感谢