|
January 2005
Shell Corner: Zsh Suite of "keeper" Functions
January 2005
Hosted by Ed Schaefer
One of the newer Unix shell is the Z Shell. If you're not familiar with Zsh, it resembles ksh, but has many enhancements; it's the ksh on steroids. This month, Bart Schaefer introduces his Zsh suite of "keeper" functions.
This One's a "Keeper"
submitted by Bart Schaefer
Several weeks ago during a discussion on the Zsh-users mailing list, the question was raised of how — without resorting to reading and writing a lot of temporary files — one could capture the output of a shell action (such as generating file names from a pattern) so that the output could then be reused in future shell actions or commands. I responded by mentioning a function and corresponding alias that I have used for quite some time as part of my Zsh configuration. This article summarizes the mailing list discussion that ensued, because it illustrates a number of useful Zsh concepts and techniques in the course of developing a new tool for the Zsh Line Editor (ZLE).
Zsh, or the Z Shell, is a command interpreter similar to others whose names you may recognize, such as bash, ksh, tcsh, csh, or sh. The shells bash, ksh, and Zsh all share a syntax based on that of sh, which was the original Unix command interpreter, but Zsh extends the shell with many other features, including some borrowed from tcsh and csh. One of these extra features is ZLE, a programmable editor for inputting shell commands and programs when using the shell interactively.
To explain in detail every Zsh technique used in this article would require too much space, so readers may need to look elsewhere for a longer introduction. I'm assuming readers are familiar with the setopt command, parameter assignment, parameter expansion syntax, and basic shell pattern characters.
|