From the course: Learning Zsh

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Functions

Functions - Unix Tutorial

From the course: Learning Zsh

Start my 1-month free trial

Functions

- [Narrator] In Z Shell you can also define and use functions, which are little pieces of script that you can use to compose your own custom functionality. We'll cover scripting later on, but functions pop up here and there, so it's important to know what they are and how to use them. To define a function, we provide a name and a set of parenthesis. The name will be what we type to use or call the function in the shell. Let's define a quick function to use a few options for the LS command. I'll start writing a function by providing a name. I'll call this ML, short for My LS. I'll give it a set of parenthesis and then an opening curly brace. Now I'm in the function editor and I'll start typing my function with LS dash LAH. And then I'll end the function with the closing curly brace. Then I can call that function by typing ML. And now I see the output of the LS command using the options that I specified. But if I wanted…

Contents