all repos — min @ null

A small but practical concatenative programming language.

site/contents/learn-shell.md

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
-----
content-type: "page"
title: "Learn: Shell"
-----
{@ _defs_.md || 0 @}

The min executable also provide an interactive REPL (Read-Eval-Print Loop) when launched with the `-i` flag:

> %min-terminal%
> [$](class:prompt) min -i
> <span class="prompt">&#91;/Users/h3rald/Development/min&#93;$</span>

Although not as advanced, the min REPL is not dissimilar from an OS system shell like Bash, and as a matter of fact, it provides many functionalities that are found in other shells or command prompts, such as:

* Auto-completion
* Persistent line history
* A customizable prompt
* Access to environment variables

...plus in can obviously leverage the entire min language for complex scripting.

## Autocompletion and shortcuts

The min shell features smart tab autocompletion and keyboard shortcut implemented using the [nimline](https://github.com/h3rald/nimline) library.

The following behaviors are implemented when pressing the `TAB` key within:

Context                                                        | Result
---------------------------------------------------------------|--------------
...a string                                                    | Auto-completes the current word using file and directory names.
...a word starting with `!`, `!!`, `!"` `!!"`, `&`, `&"`       | Auto-completes the current word using executable file names.
...a word starting with `$`                                    | Auto-completes the current word using environment variable names.
...a word starting with `'`, `~`, `@`, `#`, `>`, `<`, `*`, `(` | Auto-completes the current word using symbol names.

Additionally, the following common shortcuts are also available:

Key            | Effect
---------------|------------------------
`INSERT`       | Switches between insert and replace mode.
`UP`           | Displays the previous history entry.
`DOWN`         | Displays the next history entry.
`CTRL+d`       | Terminates the min shell.
`CTRL+u`       | Clears the current line.
`CTRL+b`       | Goes to the beginning of the line.
`CTRL+e`       | Goes to the end of the line.

> %tip%
> Tip
> 
> If you want, you can define your own keyboard shortcuts using the {#link-operator||io||mapkey#} operator.


## Shell configuration files

When the min interpreter is first launched, the following files are created automatically in the $HOME directory (%USERPROFILE% on Windows).

### .minrc

This file is interpreted first every time min is run. By default it is empty, but it can be used to define code to execute at startup.

### .min\_history

This file is used to persist all commands entered in the min shell, and it is loaded in memory at startup to provide line history support.

### .min\_symbols

This files contains all symbol definitions in JSON format that were previously-saved using the {#link-operator||lang||save-symbol#} symbol. Symbols can be loaded using the {#link-operator||lang||load-symbol#} symbol.

{#link-learn||extending||Extending min#}