What is a Terminal?
Much of the terminology used when discussing modern terminals comes from history, which can make understanding terminals seem more confusing than it should be. A small amount history can help provide some background information to help some of the concepts be more relatable. Early computers were comprised of multiple refrigerator-sized cabinets, each of which performed one of the basic tasks of the system. For example, one cabinet would contain the "central processing unit " (CPU), while other cabinets held tape drives , disk drives , punched-card readers , a line printer , and any other peripherals that were available to the computer. The user-interface to these computers consisted of a keyboard and some means of displaying the output from the computer, such as a sequence of light bulbs or later a Cathode-ray Tube (CRT) display , connected to the computer via cables. The user-interface was typically arranged into a "console ", where the operator could sit and interact with the computer. Since the user-interface represented the point at which electrical signals "enter" and "exit" the network, the user-interfaces themselves became known as "terminals ". Standardization As often happens in technology development, there were initially a wide range of competing technologies, but over time market forces and economies of scale led these competing technologies to converge towards standardization around a handful of those technologies, the names of which have become much of the jargon that surrounds the terminal today. Early terminals were electro-mechanical "Teletype writers", generally shortened to "TTY ", which is a term still used today when interacting with the terminal. As with a modern keyboard, each key on the TTY represented a human-readable character such as a letter, number, punctuation, etc. As the user would press a key to input data into the computer, each key would be "encoded " into a sequence of 8 1s and 0s called bytes , which could be understood by the computer. These bytes were sent over the cable to the CPU, which performed the requested operations, then the resulting byte(s) were transmitted back to the terminal where they were "decoded" back into characters for human-consumption. The rules used for encoding and decoding each character eventually became the ASCII standard. Despite the benefits of standardization, the ASCII standard was written to support US English, which led to several extensions in order to support other languages, which eventually led to the UTF-8 standard which unified the various extensions into a single encoding that is broadly in use today. Over time display technologies evolved which led to the introduction of "video terminals" (VT) which allowed text and other graphical information to be displayed on a screen. Some of the most popular video terminals were the VT100 and later VT200 series, which introduced support for the ANSI escape codes that have become standards that are still in use today. Emulation As microprocessor technology advanced and the cost of memory and other peripherals dropped, terminals began to handle increasingly-advanced operations, which led to the introduction of "intelligent terminals ", which differentiated them from the "dumb terminals" they replaced. In order to make the newer terminals "backward compatible " with existing software, these terminals included hardware to "emulate " the older devices. Over time the emulation functions were implemented in software, which eventually led to the introduction of fully-software "terminal emulators " that could offer features that would have been difficult to impossible to implement in hardware, such as command-line completion and syntax highlighting . With the introduction of terminal emulators, "the terminal" became a software window that is opened in order to gain access to the operating system . The software that provides this access is called "the shell", which is the subject of the next section.
Look-Arounds in Neovim Patterns
Look-arounds are used to check what comes before or after, without consuming or capturing. ("Without consuming" means that matches for look-around assertions no not become part of the string to be replaced. Look-around patterns have two components: The main pattern to match, and a "test" pattern that will be used to qualify the main pattern's match The test pattern does not consume or capture any text, it is purely a logical test. One can think of look-arounds as "conditional patterns". That is, they create patterns that only match if another condition is met. Look-arounds come in two types: Positive Match this pattern if the test pattern also matches Negative Match this pattern if the test pattern does not match While each look-around applies in one of two directions: Ahead The test pattern is applied to the right of the main pattern Behind The test pattern is applied to the left of the main pattern We will take a look at each of these in the following sections.
cat
cat is a command that reads one or more files, concatenates them, and writes them to standard output (stdout ), which by default prints the contents to the screen. This command uses the call signature: cat{options}{paths} If no path is specified, then this command receives input from stdin . If one path is specified, then this file is read and passed to stdin. If multiple paths are specified, then they are each read in sequence and passed to stdin. Basic Usage As a quick review, lets start with a file fruits.txt with the following contents: apple banana watermelon grape strawberry We can print the contents to the screen using the following command: ninja$: cat fruits.txt apple banana watermelon grape strawberry ninja$: Now, suppose we have a second file animals.txt with the following content: bear chicken duck We can concatenate the files and print them to the screen with the following command: ninja$: cat animals.txt fruits.txt bear chicken duck apple banana watermelon grape strawberry ninja$: Options Although most invocations of the cat command use the simple call signature, there are a few useful options available. Adding line numbers cat --number (or cat -n for short) returns each line prefixed with a line number, which can be handy in some cases: ninja$: cat --number fruits.txt 1 apple 2 banana 3 watermelon 4 grape 5 strawberry ninja$: Squeezing empty lines The cat command also provides an option for "squeezing" multiple blank lines down to a single blank line. For example, given a file that contains various blank lines: one two three this option can be used to: ninja$: cat --squeeze-blank blanks.txt one two three ninja$:
echo
The echo command is used to print a line of text to stdout . In many cases this is used to initiate a command or pipeline with the contents of a text string. Various options are supported, though most applications use the simple call signature: echo{string} ninja$: echo Hello World! Hello World! ninja$: