- Trick Out Your Terminal in 10 Minutes or Less
- Anne Bonner
- The Nuggets translation Project
- Permanent link to this article: github.com/xitu/gold-m…
- Translator: lihaobhsfer
- Proofread by: Wangalan30, Baddyo
10 minutes to change the terminal
How to make a better, faster, stronger, sexier terminal in just a few minutes
Time spent staring at a terminal need not be painful
Without a lot of time or effort, you can transform your terminal from an ugly white block into a beautiful, smooth, fun and useful powerful tool.
The terminal is a great tool. You can run the whole world in that. Why waste your time on a tool you don’t like?
When you first start your programming journey, you’ll quickly find that you’re spending a lot of time using terminals. You might want to become a programmer or developer, or be interested in artificial intelligence, machine learning, data science, or any other kind of career. Whichever path you choose, take a few minutes to get comfortable with your terminal and make it feel comfortable.
If you’re a new Mac programmer and hate the blank white box, help is at hand.
Built-in Mac terminal
If you have a Mac, you already have a terminal window. Even if you’ve done some basic customization, you don’t want to stare at the big white box all day:
It’s there, it’s functional, and that’s good. But with almost no effort, you can turn your terminal into a tool that you enjoy using and that makes your life a lot easier.
Terminal vs. iTerm
You don’t have to use Terminal! There is a much improved terminal application called iTerm, which is much easier to customize and has a lot of cool features. You can search in it, you can display it in columns. You can do so many things you never even thought of doing before.
You can make it sexy, practical, and not have to work too hard!
Just go to the website and hit the big download button. Once downloaded, open and install it like any other app. (If you’re interested, you can check out the download link for iTerm3 here.)
The first window you see looks like this:
We’re just getting started.
Unshow login
You probably don’t want to see that “recently logged in” message every time you open a terminal. Execute the following command to turn it off:
touch ~/.hushlogin
Copy the code
Download some cool stuff
Note that you may need to shut down and restart the terminal for the changes to take effect.
If you don’t see any changes, turn off the terminal and try again.
Homebrew
Homebrew is one of the must-have items in your Arsenal. They call themselves “the missing package manager in Mac OS,” and they’re not kidding. They install things you need that Apple doesn’t install for you.
Run the following command to install Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Copy the code
It pauses and tells you about its installation process. This instruction is very useful and I highly recommend it. Homebrew is our savior.
Zsh
The default shell is bash, which is fine if you want to stick with it. But Zsh is more customizable and has a reputation for being faster. One cool thing Zsh does is auto-complete. At any time, you can hit Git C and then TAB, and you’ll see a help window that offers autocomplete suggestions.
Also, Zsh has some great plugins that you don’t want to miss. It’s also Mac pre-built, but it doesn’t always automatically update to the latest version, so you’ll need to run:
brew install zsh
Copy the code
Oh-My-Zsh
Like Zsh? Then you must install oh-my-zsh! It is an open source framework with thousands of help, functions, plug-ins, and themes for managing your Zsh configuration. Run the following command to download:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
Copy the code
The plug-in
You can find the full list of official plug-ins here. They are out-of-the-box, you just need to enable them in your ~/.zshrc file. (Don’t walk away, it’s a lot easier than it sounds!)
To see what is available immediately, go to the plug-ins page. Swipe down to see what plug-ins you can use out of the box. You may need Git, Github, Python, Sublime, VSCode, or something more handy.
You will definitely want to install plugin Z.
Adding plug-ins is easy, but if you’re new to terminals, the instructions might be a little confusing. If you want to make changes like this, you need to edit the ~/.zshrc file. It sounds complicated, but it’s actually quite simple. Run the following command to open the file:
open ~/.zshrc
Copy the code
This will open the file you want to modify. Be sure to treat this file well. Any changes made here will affect the final run.
As you scroll through the file, you’ll see that you can modify some configurations by uncommenting them. You can also add your own changes in the margins.
Want to add or remove plug-ins? Scroll down to this section:
# Which plugins would you like to load?
# Standard plugins can be found in ~/.oh-my-zsh/plugins/*
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git)
Copy the code
It looks like they want to make it easy!
Now you can add any plug-ins you want to use. For example, change the last line to
plugins=(git z github history osx pip pyenv pylint python sublime vscode)
Copy the code
Save the file and you’re ready!
Syntax highlighting
You need Zsh syntax highlighting. It will tell you whether the command is valid or not before it runs. It’s very convenient.
To enable syntax highlighting, run
cd ~/.oh-my-zsh && git clone git://github.com/zsh-users/zsh-syntax-highlighting.git
echo "source ${(q-)PWD}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
Copy the code
Then run the following command to enable it
source ~/.oh-my-zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
Copy the code
Restart the terminal for the modification to take effect.
Z
I love the Z plugin. Very, very, very much! The Z plugin takes us to the next level. It makes using a terminal very simple! Run the following command to install it:
brew install z
Copy the code
(Hopefully, you’ve already added the Z plugin.)
Z is very good, very smart. If you keep typing the full path like this:
cd this/is/the/path/to/the_file/ThisOne
Copy the code
Now you can do this:
z thisone
Copy the code
So you can get to the directory! You only need to do a few normal operations, and Z will know what you like to do, and then you’ll be free.
For example, if you often need to access the “Repos” folder, typing CD Repos in any directory is unlikely to work.
But now you can just type Z repos and instantly jump to that directory from anywhere!
Sublime Text
If your preferred Text editor is Sublime Text, you can set a shortcut to Sublime to simplify the process. This way, you can use subl whenever you want to open a file with Sublime (or create a new file and Sublime opens it).
If you want to create a new file called test.txt and open it with Sublime, type:
subl test.txt
Copy the code
This opens Sublime and creates a brand new text file named test.txt.
On a Mac with Zsh, this is the simplest method I’ve found. First make sure your Sublime Text is installed in the application folder. To make this directive work, run the following command to create a new directory under ~/bin:
mkdir ~/bin
Copy the code
Then run this:
ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl
Copy the code
Then run the following command to add a line to the ~/.zshrc file:
echo 'export PATH=$PATH:$HOME/bin' >> ~/.zshrc
Copy the code
Then set Sublime as your default editor with the following command:
echo "export EDITOR='subl' -w" >> ~/.zshrc
Copy the code
After the terminal is restarted, run the following command to test whether the shortcut takes effect:
subl .
Copy the code
This will instantly open Sublime for you!
Let’s make it more aesthetically pleasing
While there are many themes you can use to modify the look of your terminal window, you may want to start with the simplest.
Open iTerm and click “Preferences” in the iTerm column of the menu bar. This will pop up a window with many options. In the “Colors” TAB, you can select the Colors you like, or you can select options in the “Color Presets” drop-down menu. You can choose a dark theme, or choose some simple colors. It’s also easy to change the font and size under the “Text” TAB.
You can always import your favorite themes. I usually use the color scheme in Atom, but of course you have a lot of options. You can browse the GitHub repository to see some examples.
If you want to install a custom iTerm theme, just go to the GitHub repository and click the icon at the top to download the theme. (I downloaded the ZIP file directly. After downloading it, double-click to unzip it.)
Next, go to “Preferences” and click on the “Colors” TAB and click “Import” in the “Color Presets” drop-down menu. You can choose the color theme you want here. It will pop up a access window. If you want to use Atom theme you can go to Schemes in the folder you downloaded and select Atom.itermcolors and click open.
Then you can select “Atom” from the drop down menu!
If you want to Change the Font or size, go to the “Text” TAB and click “Change Font” to do it.
Monaco looks good on the 14th.
Adjusting window transparency is also easy. Sometimes you might want to keep an eye out for processes that are overlaid at the bottom of a terminal window. As a beginner programmer, you may need to make sure that your work follows the tutorial to the letter. This feature will help you!
Go to the “Window” menu and adjust the slider under “Transparency” to find the right amount of Transparency for you.
Do what you want
Never forget: you make your own decisions. Make your world cool! This article has only scratched the surface. There are many ways to customize your own terminal.
Have fun!
If you’ve come up with a terminal configuration that pleases you, let us have a look in the comments below! As always, feel free to contact me on linkedin @annebonnerData.
Thanks for reading!
If you find any mistakes in your translation or other areas that need to be improved, you are welcome to the Nuggets Translation Program to revise and PR your translation, and you can also get the corresponding reward points. The permanent link to this article at the beginning of this article is the MarkDown link to this article on GitHub.
The Nuggets Translation Project is a community that translates quality Internet technical articles from English sharing articles on nuggets. The content covers Android, iOS, front-end, back-end, blockchain, products, design, artificial intelligence and other fields. If you want to see more high-quality translation, please continue to pay attention to the Translation plan of Digging Gold, the official Weibo, Zhihu column.