Snippets

ConsoleZ

Snippets

Dialog Box

Cancel

Close the snippet dialog box.
You can press this button or the escape key.


OK

Close the snippet dialog box and sends the snippet command into the current console view.
You can press this button or the enter key.


Show snippet information

If checked, information on snippet (author, version, code) are visible in dialog box bottom.


Opens default email application to contact author.


www

Opens author's web site in default web browser.


Edit

Opens the snippet XML file in default XML editor.
You can configure your default text editor by creating/modifying this registry key: HKEY_CURRENT_USER\SOFTWARE\Classes\SystemFileAssociations\text\shell\edit\command.

For example:
HKEY_CURRENT_USER\SOFTWARE\Classes\SystemFileAssociations\text\shell\edit\command
(default) REG_SZ "C:\Program Files (x86)\Notepad++\notepad++.exe" %1


XML file

Snippet's definition is stored in XML file. Each XML file contains a collection of one or more snippets.
By default, snippets files location is Snippets sub-directory of the settings directory. The settings directory is the directory containing your configuration file. So usually snippets are located in %appdata%\Console\Snippets.

XML files schema:

ConsoleZSnippets

A snippets collection. Root element of XML schema. See XML file example.


Attributes
None.

Child Elements

ElementDescription
DownloadUrl Required element.

Contains download URL. There must be exactly one DownloadUrl element in ConsoleZSnippets element.
Snippet Required element.

Contains snippet definition. You can define one or multiple Snippet elements in ConsoleZSnippets element.

Parent Elements
None.


DownloadUrl

Download URL.

Attributes
None.

Child Elements
None.

Parent Elements

ElementDescription
ConsoleZSnippets Root element of XML schema.


Snippet

Snippet definition. See dialog box from XML example.

Attributes
None.

Child Elements

ElementDescription
Header Required element.

Specifies general information about the command snippet. There must be exactly one Header element in Snippet element.
Declarations Optional element.

Contains the literals of a command snippet that you can edit. There may be zero or one Declarations element in Snippet element.
Code Required element.

Specifies the code that you want to insert. There must be exactly one Code element in Snippet element.

Parent Elements

ElementDescription
ConsoleZSnippets Root element of XML schema.


Header

Specifies general information about the command snippet.

Attributes
None.

Child Elements

ElementDescription
Title Required element.

The friendly name of the command snippet. There must be exactly one Title element in a Header element.
Description Required element.

A description of the command snippet. There must be exactly one Title element in a Header element.
Author Required element.

The name of the person or company that authored the command snippet. There must be exactly one Title element in a Header element.
Version Required element.

The command snippet version. There must be exactly one Version element in a Header element.
ShellTypes Optional element.

Contains shell types for which command snippet is usable. There may be zero or one ShellTypes element in Header element.

Parent Elements

ElementDescription
Snippet Snippet definition.


Title

Opens author's web site in default web browser.
Attributes
None.

Child Elements
None.

Parent Elements

ElementDescription
Header Specifies general information about the command snippet.


Description

A description of the command snippet.

Attributes
None.

Child Elements
None.

Parent Elements

ElementDescription
Header Specifies general information about the command snippet.


Author

The name of the person or company that authored the command snippet.

Attributes

AttributeDescription
Url Optional attribute.

Author's web site.
Email Optional attribute.

Author's email address.

Child Elements
None.

Parent Elements

ElementDescription
Header Specifies general information about the command snippet.


Version

The command snippet version.

Attributes
None.

Child Elements
None.

Parent Elements

ElementDescription
Header Specifies general information about the command snippet.


ShellTypes

Contains shell types for which command snippet is usable.

Attributes
None.

Child Elements

ElementDescription
ShellType Optional element.

Specifies shell types for which command snippet is usable. There may be zero, one or multiple ShellType elements in ShellTypes element.

Parent Elements

ElementDescription
Header Specifies general information about the command snippet.


ShellType

Specifies shell types for which command snippet is usable.

Attributes
None.

Child Elements
None.

Parent Elements

ElementDescription
ShellTypes Contains shell types for which command snippet is usable.


Declarations

Contains the literals of a command snippet that you can edit.

Attributes
None.

Child Elements

ElementDescription
Literal Optional element.

Contains literals. You can define 0 to 99 Literal elements in Declarations element.

Parent Elements

ElementDescription
Snippet Snippet definition.


Literal

Defines the literals of the command snippet that you can edit.
Attributes
None.

Child Elements

ElementDescription
ID Required element.

Specifies a unique identifier for the literal. There must be exactly one ID element in a Literal element.
ToolTip Required element.

Contains literals. You can define 0 to 99 Literal elements in Declarations element. There must be exactly one ToolTip element in a Literal element.
Default Required element.

Contains literals. You can define 0 to 99 Literal elements in Declarations element. There must be exactly one Default element in a Literal element.

Parent Elements

ElementDescription
Declarations Contains the literals of a command snippet that you can edit.


ID

Specifies a unique identifier for the literal.

Attributes
None.

Child Elements
None.

Parent Elements

ElementDescription
Literal Defines the literals of the command snippet that you can edit.


ToolTip

Describes the expected value and usage of the literal.

Attributes
None.

Child Elements
None.

Parent Elements

ElementDescription
Literal Defines the literals of the command snippet that you can edit.


Default

Specifies the default value of the literal.

Attributes
None.

Child Elements
None.

Parent Elements

ElementDescription
Literal Defines the literals of the command snippet that you can edit.


Code

Specifies the code that you want to insert.

Attributes

AttributeDescription
Delimiter Optional attribute.

Specifies the delimiter used to describe literals in the code. By default, the delimiter is $.

Child Elements
None.

Parent Elements

ElementDescription
Snippet Snippet definition.


Here an example of XML file:

<?xml version="1.0" encoding="utf-8"?> <ConsoleZSnippets> <DownloadUrl>http://example.com/download/system.xml</DownloadUrl> <!-- ping --> <Snippet> <Header> <Title>ping</Title> <Description>ping command</Description> <Author Url="http://example.com" Email="[email protected]">YourName</Author> <Version>1.0</Version> <ShellTypes> <ShellType>cmd</ShellType> <ShellType>powershell</ShellType> </ShellTypes> </Header> <Declarations> <Literal> <ID>target_name</ID> <ToolTip>The target name.</ToolTip> <Default>localhost</Default> </Literal> <Literal> <ID>count</ID> <ToolTip>Number of echo requests to send.</ToolTip> <Default>4</Default> </Literal> <Literal> <ID>timeout</ID> <ToolTip>Timeout in milliseconds to wait for each reply.</ToolTip> <Default>500</Default> </Literal> </Declarations> <Code Delimiter="$"> <![CDATA[ping.exe -4 -n "$count$" -w "$timeout$" "$target_name$" ]]><!-- line return, the command is launched after clicking OK --> </Code> </Snippet> <!-- restart --> <Snippet> <Header> <Title>restart</Title> <Description>restart computer</Description> <Author Url="http://example.com" Email="[email protected]">YourName</Author> <Version>1.0</Version> <ShellTypes> <ShellType>cmd</ShellType> </ShellTypes> </Header> <Declarations> <Literal> <ID>comment</ID> <ToolTip>Comment on the reason for the restart or shutdown.</ToolTip> <Default>I have a really good reason!</Default> </Literal> </Declarations> <Code Delimiter="$"> <![CDATA[shutdown /r /t 0 /c "$comment$"]]><!-- no line return, you must press enter after clicking OK --> </Code> </Snippet> <!-- hello world --> <Snippet> <Header> <Title>hello world</Title> <Description>The most trivial snippet!</Description> <Author Url="http://example.com" Email="[email protected]">YourName</Author> <Version>1.0</Version> <ShellTypes> <ShellType>cmd</ShellType> </ShellTypes> </Header> <Code> <![CDATA[@echo hello world]]> </Code> </Snippet> <Snippet> <Header> <Title>hello world</Title> <Description>The most trivial snippet!</Description> <Author Url="http://example.com" Email="[email protected]">YourName</Author> <Version>1.0</Version> <ShellTypes> <ShellType>powershell</ShellType> </ShellTypes> </Header> <Code> <![CDATA[Write-Host 'hello world' -ForegroundColor yellow]]> </Code> </Snippet> </ConsoleZSnippets>

Here an example dialog box from XML: