zsh
Start the Z shell
TLDR
Start an interactive shell session
Execute specific [c]ommands
Execute a specific script
Check a specific script for syntax errors without executing it
Execute specific commands from stdin
Execute a specific script, printing each command in the script before executing it
Start an interactive shell session in verbose mode, printing each command before executing it
Execute a specific command inside zsh with disabled glob patterns
SYNOPSIS
zsh [ options ] [ arguments... ]
zsh [ options ] [ script_file [ arguments... ] ]
PARAMETERS
-l, --login
Behave as a login shell. This usually means sourcing .zprofile and .zlogin.
-i, --interactive
Force the shell to be interactive, even if standard input/output are not terminals.
-c, --command string
Read commands from string. If there are arguments, the first argument is assigned to $0, and subsequent arguments to $1, $2, etc.
-s, --stdin
Read commands from standard input. This is the default if no script_file is given and standard input is a terminal.
-f, --no-rcs
Skip reading all startup files (.zshenv, .zprofile, .zshrc, .zlogin, .zlogout).
-v, --verbose
Print shell input lines as they are read. Useful for debugging scripts.
-V, --version
Print the version number of the zsh executable.
DESCRIPTION
zsh is a powerful Unix shell that functions as both an interactive login shell and a command interpreter for shell scripting. It is an extended version of the Bourne shell (sh) with a large number of enhancements, including features from ksh and csh.
Key attributes of zsh include highly configurable command-line editing, comprehensive history mechanisms, advanced globbing (wildcard expansion), and a sophisticated completion system that can be programmed for specific commands and arguments. It offers greater customization and more powerful features than many other shells, making it a popular choice for developers and power users who require a flexible and feature-rich command-line environment. Its extensibility through plugins and themes, often managed by community frameworks like Oh My Zsh, further amplifies its utility and user experience.
CAVEATS
The extensive customization options and powerful features of zsh can lead to a steeper learning curve compared to simpler shells like bash. Complex configurations, especially with numerous plugins, might also impact shell startup performance or resource usage. Users may need to invest time in understanding its various configuration files and options.
CONFIGURATION FILES
zsh uses a series of startup files that are read in a specific order depending on whether the shell is a login shell, interactive shell, or invoked as a script. These include .zshenv (always sourced), .zprofile (for login shells), .zshrc (for interactive shells), .zlogin (after login), and .zlogout (on logout). Understanding their hierarchy is crucial for effective customization.
POPULAR FRAMEWORKS
The popularity of zsh has been greatly boosted by community frameworks such as Oh My Zsh and Prezto. These frameworks provide a structured way to manage configurations, themes, and plugins, simplifying the process of customizing zsh and adding advanced functionalities like syntax highlighting, auto-suggestions, and specific command aliases.
ADVANCED COMPLETION SYSTEM
One of zsh's most praised features is its highly programmable completion system. Unlike simpler shell completions, zsh can intelligently complete commands, options, arguments, and even values based on context, file types, or output from other commands. This powerful feature significantly enhances productivity on the command line.
HISTORY
zsh was originally written by Paul Falstad in 1990 while he was a student at Princeton University. Its name is derived from the Yale professor Zhong Shao, whose user ID was 'z'. Over the decades, zsh has evolved through community contributions, gaining significant traction due to its advanced features and flexibility. Its adoption surged further with the advent of community-driven configuration frameworks like Oh My Zsh, which simplify its setup and extend its capabilities, making it accessible to a broader user base beyond just power users.