Warning
This is still very much an experiment. I still am changing significant parts of the syntax and semantics. At this point, this repository has fewer than 10 stars, so I will be operating as if I am the only user. If you are using it, have feedback, or just want to say hello, you can email [email protected] or use the GitHub discussions.
mshell is my personal scripting language, meant to replace short shell scripts (< ~100 LOC) and other shell one-liners.
A concatenative language is a good fit for this purpose, as it allows for easy composition of simple functions and pipelines.
The goal is to provide most of the simple Gnu utilities as part of the language, while making calls to external programs and pipelines simple and easy.
Future goals are to even add some type safety.
The beginnings of some documentation are for now located here.
mshell is compiled to a single executable binary, so installation is straightforward.
First, download the executable from the GitHub releases page.
The assets are tar.gz files, so you would unpack them with:
tar -xvf linux_amd64.tar.gzPut that file in a directory that is in your $PATH and make sure it is marked as executable on Linux.
The other file to copy is the standard library, which is included in the release, or is at lib/std.msh in this repo.
For msh v0.13.0, put it at ${XDG_DATA_HOME:-$HOME/.local/share}/msh/v0.13.0/std.msh on Linux/macOS
or %LOCALAPPDATA%\msh\v0.13.0\std.msh on Windows.
Also create ${XDG_CONFIG_HOME:-$HOME/.config}/msh/v0.13.0/init.msh on Linux/macOS
or %LOCALAPPDATA%\msh\v0.13.0\init.msh on Windows.
That init file is required for scripts that declare VER "v0.13.0", but it is optional for interactive use and scripts without VER.
For one-off overrides, MSHSTDLIB and MSHINIT can point to exact startup files for interactive use and scripts without VER.
Scripts with VER "vX.Y.Z" always use the startup files for vX.Y.Z.
An example install script is at install.sh in this repository.
Best way to understand purpose and syntax of mshell is to see it in action.
I have ported over many of personal scripts that used to be done with sh or Python in my personal dotfiles.
Take a look through this script directory and you'll find many real life examples.
Otherwise, there are some other examples here
Here are some examples.
Better Awk One-liners. Examples from the awk book, translated to mshell. You can run these examples like:
msh file_with_contents.msh < input_file_to_process.txt
awk -f file_with_contents.awk < input_file_to_process.txt
# OR (using 1st example)
msh -c 'sl len wl' < input_file_to_process.txt
awk 'END { print NR }' < input_file_to_process.txtThese examples assume the standard library is installed in the normal startup location for your current msh version.
Simpler execution of common shell idioms
| Objective | sh |
mshell |
|---|---|---|
| Print the number of files in the current directory | ls | wc -l |
"*" glob len wl |
find/xargs |
find . -t x -name '*.sh' -print0 | xargs -0 mycommand |
[mycommand [find . -t x -name "*.sh"]]o; |
head |
head -n 10 |
sl :10 uw |
tail |
tail -n 10 |
sl :-10 uw |
wc |
wc -l |
sl len wl |
grep |
grep 'pattern' |
sl ("pattern" in) filter uw |
cut |
cut -d ';' -f 2 |
sl (";" split :1: wl) each |
- VS Code extension is available on the Marketplace:
MitchellPaulus.mshell. - Sublime Text syntax highlighting is available in
sublime/msh.sublime-syntax. - Notepad++ light and dark user-defined language files are available in
Notepad++/. - Vim/Neovim syntax highlighting is available via
mshell-vim. - A language server is bundled with the CLI, providing builtin hover information, completion on
@variables, and scope-aware variable renaming.
- Job control. We don't have CTRL-z or
bg/fgfunctionality right now. - User defined abbreviations (like fish). Right now you get my hard-coded ones, sorry.
- Type checking.
- Improved error messages.