preface

The command line is an important part of programmers’ daily work. An excellent command line environment should not only have powerful functions, but also be beautiful in appearance, so that programmers can have a more relaxed and happy working mood. Maybe your current command line looks like this:






let’s go

Step 1: Upgrade your terminal, please install iterm, ZSH,oh-my-zsh

Step 2: Download, install, and use font colors

  1. Click “Download Zip” to create a directory itermThemes on your gist desktop. Unpack the zip file and move the files in the directory to itermThemes.
  2. Open Terminal, go to the itermThemes directory (CD Desktop/itermThemes), then copy the following code to the command line, press Enter to execute:
for f in *; do
 THEME=$(basename "$f")
 defaults write -app iTerm 'Custom Color Presets' -dict-add "$THEME" "$(cat "$f")"
done
Copy the code

This code iterates through the color codes in the directory and names the result ‘matrix_COLOR_scheme_2’ and stores it in iterm’s custom colors

  1. The preferences path is iTerm2, Preferences, Profiles, Colors, color Presets, “Matrix_COLOR_scheme_iterm2” As shown below:



    With the font color configuration complete, your Terminal should now have a preliminary cool effect:

    In order to achieve the effect we set before, there is a more important step to do.

Powerlevel9k is a powerful theme that displays your current directory, your current Git branch, and the execution time of your input commands in real time:

  1. Run the following command in your terminal:
$ git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k
Copy the code

This command will clone the Powerlevel9k repository into your oh-my-zsh custom theme folder. Call in your ZSH configuration with your familiar editor and replace the ZSH theme. Such as:

vim ~/.zshrc
ZSH_THEME="powerlevel9k/powerlevel9k"
Copy the code
  1. Install the Powerline font with the following command:
# clone
git clone https://github.com/powerline/fonts.git --depth=1
# install
cd fonts
./install.sh
# clean-up a bit
cd. rm -rf fontsCopy the code
  1. Select powerline Font in Iterm Preferences and use it. The operation path is Iterm, Preferences, Profiles, Text, Change Font,Select Meslo LG M for Powerline. As shown below:



    Now you have a cool terminal that will make your work environment even more enjoyable.

conclusion

Configuration is just the beginning. There are many more interesting features and custom configurations for iTerm, Oh-my-Zsh, and Powerlevel9k and plug-ins to play with. For example, I can add the following configuration to ZSHRC to reduce the file path shown in each command line. To make more room for your input:

#Shorten directory shownPOWERLEVEL9K_SHORTEN_DIR_LENGTH = 1 POWERLEVEL9K_SHORTEN_DELIMITER truncate_from_right POWERLEVEL9K_SHORTEN_STRATEGY = = "" ""#Set default user to avoid showing 'user' on every lineWhoami DEFAULT_USER = ""Copy the code

Of course, everyone has their own aesthetic, and you can choose to use other colors or fonts as long as you’re happy.