Unix Review > Archives > 2005 > January 2005

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.

Sys Admin Spotlight

CMP DevNet Spotlight

C++/CLI: Cloning
Making copies of heap-based objects

In the News

CD-ROM

Sys Admin and The Perl Journal CD-ROM version 11.0

Version 11.0 delivers every issue of Sys Admin from 1992 through 2005 and every issue of The Perl Journal from 1996-2002 in one convenient CD-ROM!

Order now!




MarketPlace

�Six Sigma� Certified?
100% Online-Six Sigma Certificate From Villanova -Find Out More Now.

Project Management-Online
Nation's Leading Online PMP Course From Villanova-Find Out More Now.

Automate Software Builds with Visual Build Pro
Easily create an automated, repeatable process for building and deploying software.

WinDev 12 - Powerful IDE
Develop 10 times faster ! ALM, IDE, .Net, RAD, 5GL, Database, 5GL, 64-bit, etc. Free Express version

Wanna see your ad here?