Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Learning Shell Scripting with Zsh
  • Table Of Contents Toc
Learning Shell Scripting with Zsh

Learning Shell Scripting with Zsh

By : Gaston Festari
2.3 (9)
close
close
Learning Shell Scripting with Zsh

Learning Shell Scripting with Zsh

2.3 (9)
By: Gaston Festari

Overview of this book

Table of Contents (13 chapters)
close
close

Function definitions


Finally, we will turn our attention to compsys, zsh's completion system. This is one of the most complex parts of the shell for users and developers alike. Before we dive into compsys, however, we need to make a quick stop and meet an actual function in the wild.

Tip

As usual, you can learn more about compsys via the manpages. Of particular interest are man zshcompsys and man zshcompwid.

Here's what one of these looks like:

hi() {
print 'Hello, world'
}

Here, we have defined the hi function, which is how we'll call it again later when we need it. This will, in turn, print Hello, world every time we use it. So let's get to it, shall we?

Open your terminal emulator of choice, and type the following (one line at a time):

% hi() {
function> print 'Hello, World!'
function> }

Notice how zsh realized this was indeed a function we were trying to define and immediately used the continuation prompt (function>), allowing you to continue working on it? How nice of zsh to wait...

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Learning Shell Scripting with Zsh
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon