Skip to Content
Learning Shell Scripting with Zsh
book

Learning Shell Scripting with Zsh

by Gaston Festari
January 2014
Beginner
132 pages
2h 45m
English
Packt Publishing
Content preview from Learning Shell Scripting with Zsh

Command correction

Completion can also correct any misspelled commands that you might have typed. We'll use the following format for our style:

zstyle ':completion:*' completer _expand _complete _correct

And we'll test the autocorrect functionality with the following:

% prnti<Tab>
corrections (2 errors)
print   printf
original
prnti

Zstyle noticed that we misspelled print and is being quite verbose regarding this. Remember you can use the Tab key to cycle through the list of available options.

Alternatively, you could use the correct option if you want a more "hold me by the hand" approach. Specifically, this option will make zsh ask you for confirmation every time it suggests a correction:

% setopt correct
% prnti<Tab>
zsh: correct 'prnti' to 'print' ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Zsh in macOS: Terminal Commands for Unix

Zsh in macOS: Terminal Commands for Unix

Karl Hadwen

Publisher Resources

ISBN: 9781783282937Supplemental Content