Z shell#Recursive globbing
{{Short description|Unix shell}}
{{Infobox software
| name = Z shell
| logo = File:Z Shell Logo Color Vertical.svg
| screenshot = Zsh 5.9 screenshot.webp
| screenshot size = 250px
| caption = Screenshot of a Zsh session
| developer = Peter Stephenson, et al.
| released = {{Start date and age|1990}}
| latest release version = {{wikidata|property|preferred|references|edit|P348|P548=Q2804309}}
| latest release date = {{Start date and age|{{wikidata|qualifier|preferred|single|P348|P548=Q2804309|P577}}
|df=yes}}
| programming language = C
| operating system = Cross-platform
| genre = Unix shell
| license = MIT-Modern-Variant{{cite web|url=http://sourceforge.net/p/zsh/code/ci/master/tree/LICENCE|title=zsh / Code / [281031] /LICENCE|publisher=Paul Falstad|access-date=February 7, 2015|archive-date=March 2, 2021|archive-url=https://web.archive.org/web/20210302213122/https://sourceforge.net/p/zsh/code/ci/master/tree/LICENCE|url-status=live}}{{cite web|url=https://spdx.org/licenses/MIT-Modern-Variant.html|title=MIT License Modern Variant}}
| website = {{url|https://www.zsh.org/|zsh.org}}
}}
The Z shell (Zsh) is a Unix shell that can be used as an interactive login shell and as a command interpreter for shell scripting. Zsh is an extended Bourne shell with many improvements, including some features of Bash, ksh, and tcsh.
Zsh was created by Paul Falstad in 1990 while he was a student at Princeton University. It combines features from both ksh and tcsh, offering functionality such as programmable command-line completion, extended file globbing, improved variable/array handling, and themeable prompts.
Zsh is available for Microsoft Windows as part of the UnxUtils collection and has been adopted as the default shell for macOS and Kali Linux. The "Oh My Zsh" user community website provides a platform for third-party plug-ins and themes, featuring a large and active contributor base.
History
Paul Falstad wrote the first version of Zsh in 1990{{cite web|url=http://groups.google.com/group/alt.sources/msg/936c7876941058ed|title=zsh - a ksh/tcsh-like shell (part 1 of 8)|publisher=alt.sources|date=December 14, 1990|access-date=September 18, 2012}} while a student at Princeton University.{{cite web|url= http://zsh.sourceforge.net/FAQ/zshfaq01.html#l3|title= Z-Shell Frequently-Asked Questions|publisher= Sourceforge.net|date= February 15, 2010|access-date= September 18, 2012|archive-date= March 2, 2021|archive-url= https://web.archive.org/web/20210302213122/http://zsh.sourceforge.net/FAQ/zshfaq01.html#l3|url-status= live}} The name zsh derives from the name of Yale professor Zhong Shao (then a teaching assistant at Princeton University) – Paul Falstad regarded Shao's login, "zsh", as a good name for a shell.{{cite web|url= http://www.guckes.net/zsh/lover.html|title= The Z-Shell (ZSH) Lovers' Page|publisher= Guckes.net|date= c. 2004|access-date= October 2, 2012|archive-date= May 17, 2017|archive-url= https://web.archive.org/web/20170517213919/http://www.guckes.net/zsh/lover.html|url-status= live}}{{cite web|url= http://www.zsh.org/mla/users/2005/msg00951.html|title= Zsh Mailing List Archive|publisher= Zsh.org|date= August 8, 2005|access-date= October 2, 2012|archive-date= March 2, 2021|archive-url= https://web.archive.org/web/20210302213117/https://www.zsh.org/mla/users/2005/msg00951.html|url-status= live}}
Zsh was at first intended to be a subset of csh for the Amiga, but expanded far beyond that. By the time of the release of version 1.0 in 1990 the aim was to be a cross between ksh and tcsh {{Ndash}}a powerful "command and programming language" that is well-designed and logical (like ksh), but also built for humans (like tcsh), with all the neat features like spell checking, login/logout watching and termcap support that were "probably too weird to make it into an AT&T product".{{ cite web | url = https://github.com/llua/zsh-1.0 | title = zsh 1.0 announcement | website = GitHub | date = 15 April 2021 }}
Zsh is available for Microsoft Windows as part of the UnxUtils collection of native Win32 ports of common GNU Unix-like utilities.{{Cite web |url=http://unxutils.sourceforge.net/ |title=Native Win32 ports of some GNU utilities |access-date=2020-07-25 |archive-date=2006-02-09 |archive-url=https://web.archive.org/web/20060209022842/http://unxutils.sourceforge.net/ |url-status=live }}
In 2019, macOS Catalina adopted Zsh as the default login shell, replacing the GPLv2 licensed version of Bash,{{Cite web|url=https://www.theverge.com/2019/6/4/18651872/apple-macos-catalina-zsh-bash-shell-replacement-features|title=Apple replaces bash with zsh as the default shell in macOS Catalina|last=Warren|first=Tom|date=June 4, 2019|website=The Verge|access-date=June 13, 2019|archive-date=June 10, 2019|archive-url=https://web.archive.org/web/20190610051842/https://www.theverge.com/2019/6/4/18651872/apple-macos-catalina-zsh-bash-shell-replacement-features|url-status=live}} and when Bash is run interactively on Catalina, a warning is shown by default.{{cite web |title=Use zsh as the default shell on your Mac - Apple Support |url=https://support.apple.com/en-us/HT208050 |access-date=1 July 2019 |archive-date=2 December 2019 |archive-url=https://web.archive.org/web/20191202143802/https://support.apple.com/en-us/HT208050 |url-status=live }}
In 2020, Kali Linux adopted Zsh as the default shell since its 2020.4 release.{{Cite web|title=Kali Linux 2020.4 Release (ZSH, Bash, CME, MOTD, AWS, Docs, Win-KeX & Vagrant) {{!}} Kali Linux Blog|url=https://www.kali.org/blog/kali-linux-2020-4-release/|access-date=2021-03-03|website=Kali Linux|language=English}}
Features
File:Zsh 5.9 new user screenshot.webp
File:Zsh-agnoster.png terminal emulator]]
- Programmable command-line completion that can help the user type both options and arguments for most used commands, with out-of-the-box support for several hundred commands
- Sharing of command history among all running shells
- Extended file globbing allows file specification without needing to run an external program such as find
- Improved variable/array handling (non-zero-based numbering)
- Editing of multi-line commands in a single buffer
- Spelling correction and autofill of command names (and optionally arguments, assumed to be file names)
- Various compatibility modes, e.g. Zsh can pretend to be a Bourne shell when run as
/bin/sh
- Themeable prompts, including the ability to put prompt information on the right side of the screen and have it auto-hide when typing a long command
- Loadable modules, providing among other things: full TCP and Unix domain socket controls, an FTP client, and extended math functions.
- The built-in
where
command. Works like thewhich
command but shows all locations of the target command in the directories specified in$PATH
rather than only the one that will be used. - Named directories. This allows the user to set up shortcuts such as
~mydir
, which then behave the way~
and~user
do. - Widgets. Both built and implemented by ordinary functions widgets can be bound to hotkeys.
- Function autoloading. A performance optimization for function that might be pre-loaded and run on demand.{{Cite book |title=Unix power tools |date=2003 |publisher=O'Reilly |isbn=978-0-596-00330-2 |edition=3 |location=Sebastopol (Calif.)}} The intent of loading functions as separate file is also to support function features across different zsh versions.
Community
A user community website known as "Oh My Zsh" collects third-party plug-ins and themes for the Z shell. As of 2024, their GitHub repository has over 2300 contributors, over 300 plug-ins, and over 140 themes. It also comes with an auto-update tool that makes it easier to keep installed plug-ins and themes updated.{{cite web |title=ohmyzsh Github |url=https://github.com/ohmyzsh/ohmyzsh |website=GitHub }}
See also
{{Portal|Free and open-source software}}
References
{{Reflist}}