custom snippet definition
A custom file consists of a series of snippets, which are bash string array type variables, like:
new=(" whats new with mint 20.3 $open_htm_front: $2> cinnamon -> https://www.linuxmint.com/rel_una_cinnamon_whatsnew.php $2> mate -> https://www.linuxmint.com/rel_una_mate_whatsnew.php $2> xfce -> https://www.linuxmint.com/rel_una_xfce_whatsnew.php")
Adding another named bash string array variable to the custom file adds just another available snippet.
declaration convention
There is an important convention you have to follow on declaring snippet variables, to make them 'visible' with --sel , --list and --show options:
The snippet variable name has to be defined at the beginning of a new line directly followed by only =(" and a newline without any extra whitespace. The actual snippet text starts on the next following line.
The snippet definition is ended by a trailing ") at the last line.
Note: Its valid bash syntax to use string variable assignments spanning several lines; there is no extra escaping of line endings needed.
This declaration convention/restriction allows to use a simple pattern matching to grep snippet names at runtime for listing purposes - thus avoiding extra meta-data or reference lists entirely.
Besides that, any valid bash variable name may be used for a snippet name; use short names for more often used snippets.
ot-snippet applies no sorting on snippets with --list, --sel or --show. You can just use your prefered order by placing snippets accordingly. The zenity dialog to select a snippet offeres sorting via a click onto the header-label.
To get an overview about current used snippet names/keys use:
ot-snippet-para --list
[...] about bbl ny bye magic press Shift+PgUp to scroll back press RETURN to close window press RETURN to close window
Create a new snippet
Open ~/bin/ot-snippet-para.txt using any text editor and add a new snippet defition to the begin of the file:
my1st=(" $2> first line of my first snippet $2> second line with an extra param '$3' $2> last line...")
After you saved your edits, test the new snippet right from a terminal (or an IRC client at some test channel):
ot-snippet-para my1st somename someparamused toomanyparams
- which should expand to:
somename> first line of my first snippet somename> second line with an extra param 'someparamused' somename> last line...")
As the new snippet sticks with the declaration convention it will be shown by --list (?) or --show (_) the same way, as it can by used with --sel (:)
ot-snippet-para : somename someparamused toomanyparams
deactivate snippet
If you want to disable snippets temporarily, its enough to comment the according lines of the snippet definition. This will not only get rid of the variable instances, but prevents the snippets from being shown/offered by: --list , --show or --sel
Just comment my1st snippet entirely and save your custom file. If you are running now again:
ot-snippet-para : somename someparamused toomanyparams
... shouldn't list your snippet any longer.
line breaks
While the first artificial line break will be removed, remaining line breaks are returned as given at the snippet, which allows to define multiline replies this way.
Having several lines available allows to place commands at a new line without any leading or trailing text, which helps to avoid confusion.
ver=(" ${P}To know your used mint version, run at a terminal: ${P}inxi -Sxx")
Be aware there are flooding limits with many IRC channels; three line snippets should likely be ok with most of them.