Zsh Mode Help
Name: | Zsh Mode |
Version: | 0.1 |
Last update: | 2021-02-25 11:19:17 |
Introduction
Zsh Mode is a mode for the text editor Alpha: it installs basic
support for editing script files for the Z Shell (aka zsh)
using the Alpha text editor.
This mode provides the following features:
- syntax coloring
- keywords completion
- electric completion of the flow control structures (like if, for,
while etc.)
- functions marking
- execution of the script from Alpha. The script is sent to the Mac
OS X Terminal application for execution.
Click on this Zsh Example link for an example syntax file.
Editing in Zsh mode
There are several ways of editing a file in Zsh mode:
- if the file has a .zsh extension, it will automatically be opened in
Zsh mode.
- if the first line of the file is
#!/bin/zsh
or any other path ending with the word "zsh", it will also automatically
be opened in Zsh mode.
- you can manually select Zsh mode from the Modes popup (🄼) located in the control bar of the document window.
Completions
There are two aspects for word completion in Zsh mode:
- you can type the first letters of a keyword (like export, typeset,
declare etc.) and hit the completion key (usually
F1
or ⌃-Tab
). Alpha will complete
the word automatically.
- for the flow control keywords, you can hit the completion key just
after the word and Alpha will insert a complete template for the
corresponding structure. For instance: type "if" followed by the
completion key in order to insert
if * ; then
*
fi
where the asterisk denotes an insertion bullet. You move from an insertion
bullet to the next one with the Tabulation key.
The flow control keywords recognized by the Zsh mode are:
case, for, func, if, ifelif, ifelse, repeat, select, until, while.
File marking
You can mark two kinds of items using the Marks popup (📖):
- the section headers, i-e lines that start with '### ' or '#### '.
- the case | for | if | until | while blocks (unless the preference
'Mark Headers Only' is set ot 1).
Parse popup
In Zsh mode, the Parse popup (⚙) of document windows displays the
function definitions found in the document. The zsh
syntax provides two forms of function definition and Zsh mode
recognizes both. For instance, you can write either
foo () {
echo bar
}
or
function foo {
echo bar
}
Key bindings
The following key bindings are defined in Zsh mode:
- Ctrl-T lets you switch to the Terminal application.
- Ctrl-X lets you execute the current window.
See the Script execution section.
Script execution
The Ctrl-X key binding lets you execute the
contents of the document window by sending it to the Mac OS X Terminal. The command takes care of launching the Terminal application if it
is not already running. Zsh mode makes some preliminary checks before
sending the script: it verifies that the execute flag is set, that the window
has Unix line endings and that is has been saved.
Note that you can set the executable flag of a file manually in
Alpha using the Info popup (🄸) located in the control bar of the
document window. There is an item called Executable… which can be
set on or off.
Known problems
Please report any problem or bug you encounter in
Alpha's Bug Tracker.
License and Disclaimer
Copyright (c) 2020-2021, Bernard Desgraupes.
All rights reserved.
The Zsh Mode package is free software and distributed under
the terms of the new BSD license:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- Neither the name of Bernard Desgraupes nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BERNARD DESGRAUPES BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.