Configuration
The config filePermalink to The config file#
Shale reads its configuration from ~/.config/shale/config.sgl, a Sigil file. You don't need one: without it, Shale uses its defaults. Here is a config file that adds a command and two abbreviations, and changes the prompt's heading:
;; A command written in Sigil. Its arguments arrive as strings.
(define-command (count-sources . directories)
(let* ((places (if (null? directories) '(".") directories))
(files (apply append
(map (lambda (directory)
(glob (string-append directory "/*.sgl")))
places))))
(display (length files))
(display " Sigil files")
(newline)))
(config
prompt: (lambda (state)
(let ((branch (prompt-git-branch state)))
(string-append (prompt-directory state)
(if branch (string-append " on " branch) ""))))
abbreviations: (abbreviations
"gs" "git status --short"
"notes" "cat notes.txt"))The file can define and import whatever a Sigil script can. It ends with a config form that holds the settings.
SettingsPermalink to Settings#
Setting | What it does |
|---|---|
| A procedure that receives the prompt's state and returns the text of the heading line. Shale draws the text in one color, with no time. When the procedure fails or doesn't return a string, Shale draws its own heading instead. |
| When |
| Short words that turn into longer commands when you type one at the start of a command and press Space or Enter. |
Two procedures read the prompt's state: the first, prompt-directory, gives the full path of the current directory, and the second, prompt-git-branch, gives the Git branch or #f. With the config above, the prompt looks like this:
/home/ada/project on main
$ Your own commandsPermalink to Your own commands#
To define a command you run like any other, with the words after it as arguments, use define-command. A command you define takes the place of a program with the same name, but a builtin such as cd still wins.
~/project $ count-sources src
2 Sigil files
~/project $ notes
buy milk
call the plumberA defined command runs inside Shale, so it has to be a command of its own: you can't pipe it, redirect it or run it in the background, though && and ; work. To make something you can pipe, write a script and put it on your path.
Changing the configurationPermalink to Changing the configuration#
Before it draws each prompt, Shale checks whether the config file has changed, and reads it again if it has. The new settings apply from the next prompt on. To read it again right away, type ,reload.
When the file has a mistake, Shale prints the file, the line and what's wrong, and keeps the settings it had. When the mistake is there at startup, Shale starts with its defaults.
Settings that only make sense on one machine can go in ~/.config/shale/local.sgl, which Shale reads after the main file. Its settings take precedence, and abbreviations from the two files are merged word by word.