Use the terminal tool iTerm2 under Mac

First popularize the Linux shell

The operating systems we use now (Windows, Mac OS, Android, iOS, etc.) are all with a graphical interface, which is simple and intuitive and easy to use; however, in the early days of computers, there was no graphical interface, and we could only control it by one by one. computer. For the graphical interface, the user can start a program by clicking an icon; for the command line, the user can start a program by entering the name of a program (which can be regarded as a command). The basic processes of the two are similar, both need to find the installation location of the program on the hard disk, and then load them into the memory to run.

In other words, the purpose of the graphical interface and the command line is the same, both of which allow the user to control the computer.

However, the only thing that can control the computer hardware (CPU, memory, display, etc.) is the kernel of the operating system. The graphical interface and the command line are just a bridge between the user and the kernel.

Due to security, complexity, cumbersome and other reasons, users cannot directly access the kernel (not necessary), and need to develop another program to allow users to directly use this program; the role of the program is to receive user operations (click on the icon, enter commands) , And perform simple processing, and then pass to the kernel, so that users can indirectly use the operating system kernel. You see, adding a layer of "agent" between the user and the kernel can not only simplify the user's operation, but also ensure the security of the kernel. Why not?

The user interface and command line are this separately developed program, which is the "agent". Under Linux, this command line program is called Shell.

Shell is an application that connects users to the Linux kernel, allowing users to use the Linux kernel more efficiently, securely, and at low cost. This is the essence of Shell.

Shell itself is not part of the kernel, it is just an application written on the basis of the kernel, it is no different from other software such as QQ, Thunder, Firefox. However, Shell also has its particularity, that is, it starts immediately after booting, and is presented to the user; the user uses Linux through the Shell. If the Shell is not started, the user cannot use Linux.

shell in mac

Mac system uses zsh as the terminal by default

You can view the current shell of the system by yourself

$ cat /etc/shells

/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
以及切换shell
chsh -s /bin/zsh
chsh -s /bin/bash

among them,

  • The configuration file of bash is -/.bash_profile
  • The configuration file of zsh is -/.zshrc is
    located in the user's home directory and is a hidden file

1. In the finder root directory, command + shift +. Display hidden files to see. At the same time, you can see that bash, csh, dash, zsh, etc. are all in this directory,
Insert picture description here

Introduction to iTerm2:

Although the terminal that comes with Mac OS is a bit inconvenient to use, and the interface is not friendly enough, iTerm2 is a relatively easy-to-use terminal tool. The common operations of iTerm2 include theme selection, statement highlighting, auto-fill suggestions, hiding user names and Host name, split screen effect, etc.
Download and install iTerm2:

1. Download address: https://www.iterm2.com/downloads.html The
downloaded file is a compressed file. After decompression, double-click to execute the program file, or directly drag it to the Applications directory.

2. You can also use Homebrew directly to install:

$ brew cask install iterm2

iTerm2 shortcut commands

In iterm2, select a certain path or a certain word, iterm2 will automatically copy it, which is very convenient.

command + enter 进入与返回全屏模式
command + t 新建标签
command + w 关闭标签
command + 数字 command + 左右方向键    切换标签
command + enter 切换全屏
command + f 查找
command + d 水平分屏
command + shift + d 垂直分屏
command + option + 方向键 command + [ 或 command + ]    切换屏幕
command + ; 查看历史命令
command + shift + h 查看剪贴板历史
ctrl + u    清除当前行
ctrl + l    清屏
ctrl + a    到行首
ctrl + e    到行尾
ctrl + f/b  前进后退
ctrl + p    上一条命令
ctrl + r    搜索命令历史

Guess you like

Origin blog.csdn.net/xiaoxiannv666/article/details/112882101