This article mainly introduces some basic concepts of terminal and shell, and focuses on ZSH – the most powerful and convenient shell and its configuration, hoping to improve the efficiency of our code farmers.

terminal

Terminal is an input and output device used to interact with a computer. It does not provide computing and processing functions. In the days of mainframes and minicomputers, computers were very expensive and huge. Usually the computer is located in a separate room, and the person operating the computer interacts with the computer in a separate room via TTY/CONSOLE. Nowadays, with the popularity of personal computers, specialized terminals are rarely seen. A keyboard for input, a display for output, and a virtual terminal, which has nothing to do with hardware, constitute a terminal in the traditional sense.

TIPS: Enior

The ENIAC is the world’s first modern electronic digital computer. It was born on February 14, 1946 at the University of Pennsylvania. It is 30.48 meters long, 6 meters wide, 2.4 meters high, covers an area of about 170 square meters, 30 operating stations, weighs 30 tons, consumes 150 kilowatts of electricity, and cost $480,000. The speed is 5,000 additions or 400 multiplications per second.

terminalTTY

TTYTeleTYpe is short for TeleTYpe, a device similar to a telegraph. This is the earliest terminal.

Its original purpose was to send and receive telegraphs over telegraph lines, but because it could both send signals via a keyboard and print them on paper tape, and most importantly, because it was cheap, it was used by the founders of Unix, Ken Thompson and Dennis Ritchie, to connect them to computers. It made it possible for multiple users to log in to the operating host from the terminal, making it the first Unix terminal.

The consoleCONSOLE

CONSOLE is a special terminal, which is integrated with the main body of the computer. It is specially used to manage the host. It can only be used by the system administrator and has higher permissions than ordinary terminals. Generally, there is only one console on a computer, but many terminals can be connected. CONSOLE and TTY are both terminals, and the difference is between the actual and the actual sons or root and non-root users.

Terminal simulator

The Terminal Emulator is also called the Terminal Emulator. Along with a keyboard and a display, it built the old terminal. Its workflow is as follows:

  1. Capture keyboard input (STDIN)
  2. Send input to a command-line program (SHELL)
  3. Get the output of the command line program (STDOUT and STDERR)
  4. Calls the graphical interface to render the output to the display

Terminal window and virtual console

There are two types of terminal emulators. One is the terminal window, which we generally run in the graphical user interface, such as gnome-Termial under GNU/Linux, Iterm2 under MAC, and WSL-Terminal under Windows. The other is called the virtual console, like on Ubuntu, with Ctrl+Alt+F1,F2… You can press Ctrl+Alt+F7 to switch back to the GUI. This is the virtual console. It is provided directly from the operating system kernel.

Practical terminal

MAC artifact – iterm2

  • The installation

    Install via BREW
    brew cask install iterm2
    Download and install iterm2 from iterm2
    Copy the code
  • configuration

    • Courier New + meslo

      # Pull the font library
      git clone https://github.com/powerline/fonts.git --depth=1
      # the install installation
      cd fonts  &&  ./install.sh
      Copy the code
    • Terminal color

      # Pull the terminal color library
      git clone https://github.com/mbadolato/iTerm2-Color-Schemes.git --depth=1
      Copy the code

    • Number of lines displayed on the terminal

shell

The shell is also called the command interpreter. It parses commands to call system calls and apis to operate the kernel, and then reads and writes to the hardware to complete the task.

It can be done through graphical shells such as Explorer. Exe for Windows, GNOME, KDE for Linux, and command-line shells. Like cmd.exe in Windows, bash in Linux, ZSH, etc.

zsh

Bash was the default shell for almost all types of operating systems until 2019, but Catalina for Mac 2019 set ZSH as the default shell. Why is that? Because ZSH is fully bash compliant and provides more functionality. It provides the following functions:

  1. Built-in spelling correction
  2. Improved command line completion
  3. Subject to support
  4. Various loadable plug-ins

The installation and switching commands are as follows:

# installation
brew install zsh
# switch
chsh -s /bin/zsh
Copy the code

oh-my-zsh

Oh-my-zsh is a tool that allows users to easily enable ZSH plug-ins, switch between prefabricated themes, and quickly customize shells.

  • Oh – my – ZSH installation

    sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
    Copy the code
  • Configure topic annoster

The plug-in

Plug-ins offer endless possibilities for ZSH.

  • git

The default installation will prompt information such as branch

  • Highlighting zsh-syntax-highlighting

    # 
    git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
    Copy the code
  • Zsh-autosuggestions are automatically prompted

    git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
    Copy the code
  • This is an automatic jump

    # installation autojump
    brew install autojump
    # add to ~/.zshrc
    [ -f /usr/local/etc/profile.d/autojump.sh ] && . /usr/local/etc/profile.d/autojump.sh
    Copy the code

reference

  1. Can you tell the DIFFERENCE between CLI, Terminal, Shell, and TTY?
  2. Iterm2 website
  3. ITerm2 + Oh My Zsh to create a comfortable terminal experience
  4. Mac Terminal Tools

This article was automatically published by ArtiPub, an article publishing platform