Marjon Cajocon

Home › mmc-shell

Open source · MIT license

mmc-shell: a portable, git-bash style shell written in C.

A bash-compatible shell with its own terminal window, written from scratch in pure C11. No installer and no dependencies — unzip it anywhere, even on a USB drive, and that folder becomes /.

  • C11
  • Windows
  • Linux
  • macOS
  • Android (Termux)

The idea

I wanted a terminal that feels like Linux or git-bash on any PC: a /home, a /usr, an /etc, and export PATH=... that just works. The folder that holds the program becomes /, so the whole development setup — home folder, settings, history, tools — travels with it. The user name is kept in /etc/user, so the home folder is the same on every PC it is plugged into.

mmc stands for Marjon Mangindo Cajocon.

mmc-shell: every feature

Portable by design

  • One executable, no installer, no dependencies. The folder it sits in becomes /; the first run creates etc/, home/<user>/, usr/bin/ and tmp/ next to it.
  • One home on every PC: the user name is kept in /etc/user, so HOME, .mmcrc, the history and .gitconfig travel with the folder whatever the login name is.
  • $MMC_DRIVE is the drive mmc is on (e.g. /d), so /etc/profile keeps working when the drive letter changes on another PC.
  • Programs you start from it — code ., git, node, go, flutter — inherit the environment you set up.

Runs bash scripts

  • 440 compatibility cases, taken from how git, gradle, flutter, npm, emsdk and the Android SDK really use bash, give the same output and exit status as bash 5.3.
  • Pipelines (|, |&), && / ||, background jobs, !, time, subshells and groups.
  • if, while, until, for x in, C-style for ((;;)), case, select, functions, break n / continue n.
  • [[ ]] with pattern matching and =~ regex (BASH_REMATCH), (( )), let and $(( )) arithmetic.
  • Every redirection: > >> < <> >| 2>&1 &>, fd duplication and closing, {fd}>file, here-docs, here-strings, exec 3>file.
  • Command substitution, $(< file), and streaming process substitution <(cmd) / >(cmd); coproc.
  • All quoting forms ($'\n', $"x"), brace expansion ({a,b}{1..3}, {01..10..2}) and tilde expansion (~ ~+ ~-).
  • The whole parameter expansion set: defaults, lengths, prefix/suffix removal, substitution, substrings, case changes, indirection, ${v@Q} and friends.
  • Indexed and associative arrays; declare with -i -l -u -r -x -n -g -A, local, readonly, namerefs.
  • Globbing with * ? [ ], POSIX classes, ** (globstar) and extglob ?( ) *( ) +( ) @( ) !( ).
  • set -euxo pipefail, trap, local -, caller, FUNCNAME, BASH_SOURCE, PIPESTATUS and the other bash variables — scripts that check BASH_VERSION run.
  • All of bash's builtins, from alias to wait, plus small fallbacks (ls cat clear mkdir env which) used only when no such program is in the PATH.
  • Many shopt options (autocd cdspell dirspell extglob globstar nullglob dotglob nocaseglob lastpipe inherit_errexit …) and bash compatibility levels compat31–compat44 / BASH_COMPAT.
  • export -f passes functions to child shells the way bash does, taking only a clean function definition — the Shellshock hole is closed.
  • Scripts saved with Windows CR LF line endings run like any other.

Interactive use

  • Line editor with history, Ctrl+R incremental search (Ctrl+S forward), word movement, Home/End and the usual Ctrl-A/E/K/U/W/L keys.
  • A kill ring (Ctrl+Y, Alt+Y), undo (Ctrl+_), transpose, Alt+U/L/C word case, Alt+. for the last word, and Ctrl+X Ctrl+E to edit the line in $EDITOR.
  • Tab completion of commands, functions and files, and bash's programmable completion (complete, compgen, compopt) — git's own git-completion.bash gives branches and options.
  • History expansion: !!, !n, !word, !$, modifiers like :h :t :s/old/new/, and ^old^new; fc to list, edit and re-run commands.
  • HISTSIZE, HISTFILESIZE, HISTCONTROL, PROMPT_COMMAND; multi-line paste runs together on Enter; unfinished commands continue with > .
  • Prompts: a two-line Parrot OS style default with the git branch and a red [✗] after a failed command, a classic git-bash one, a Powerline one with Nerd Font icons, or your own $PS1.
  • A startup banner, replaceable with your own ANSI art in /etc/banner.
  • Job control: Ctrl+Z, fg, bg, jobs, suspend on Linux and macOS; kill -STOP / -CONT works on Windows too.

Settings

  • /etc/profile for everyone, ~/.mmcrc for you, login files ~/.mmc_profile / ~/.mmc_logout, and $MMC_ENV / $BASH_ENV for scripts — all plain bash.
  • usr/bin/ is on the PATH for your own programs and scripts.

Windows paths, done like git-bash

  • / is the mmc folder, /d/env is D:\env, /tmp is %TEMP%, /dev/null is NUL.
  • Arguments and environment values that look like Linux paths are turned back into Windows paths when a Windows program starts, so git, node, go and VS Code get what they expect; switches like /c are left alone.
  • PortableGit's own GNU tools (sed, grep …) work alongside it.
  • .exe .com .cmd .bat are found without the extension, and #! scripts run with their interpreter.
  • No fork() needed and no emulation layer like MSYS2 or Cygwin: one native program calling Win32 on Windows and POSIX on Linux and macOS.

Tools for scripts

  • mmc --check a.sh reports syntax errors and commands that do not exist, without running anything — it reads the 70 shell scripts of PortableGit, Flutter, emsdk and the Android SDK cleanly.
  • mmc --complete 'git ch' prints what Tab would offer, for debugging completion scripts.
  • mmc -c, -s, -e -x -o pipefail, -n, --rcfile, and #!/usr/bin/env mmc.

mmc-term: every feature

git-bash is bash inside the mintty window; mmc has its own. One shared core draws the whole terminal — text, box drawing, cursor, selection, scrollbar, even the menu — into a pixel buffer, and a small backend per system only shows it, so it looks the same everywhere.

Tabs and panes

  • Tabs (Ctrl+Shift+T), each its own shell started in the current folder; drag them to reorder, double-click to rename, and a green dot marks a background tab with new output.
  • Split panes side by side or stacked (Ctrl+Shift+D / E), up to 8 per tab, resizable by dragging, with Alt+arrow to move between them.
  • New windows (Ctrl+Shift+N) open in the same folder, via OSC 7.

Look

  • Five themes — dark, green, gruvbox, red, light — switched with Ctrl+Shift+L, or your own colors in mmcterm.conf.
  • See-through window (Ctrl+Shift+wheel, 30–100%), full screen (F11), zoom with Ctrl +/− or Ctrl+wheel.
  • On Windows, its own title bar with round yellow / green / red buttons; snapping and resizing still work, and titlebar=native brings the system one back.

Text rendering

  • JetBrains Mono Nerd Font bundled, with Powerline symbols and Nerd Font icons; fonts in the mmc folder are found first, so the font travels too.
  • Ligatures (-> => != ===) read by mmc itself from the font's OpenType GSUB tables, one letter per cell, with the cell under the cursor shown as typed.
  • Color emoji from the system emoji font (COLR, CBDT and sbix, with its own PNG reader), including skin tones and ZWJ sequences.
  • Sharp small text: ClearType through GDI on Windows, and a built-in rasterizer with stem darkening and x-height snapping elsewhere.
  • Powerline arrows, box drawing and block characters drawn as geometry, so prompt segments join without seams at any size.
  • Underline styles and colors (double, curly, dotted, dashed), overline and blink.

Selecting, finding, copying

  • Drag, double-click and triple-click to select a word or line; selecting copies. Ctrl+Shift+C / V, Ctrl+Insert / Shift+Insert, middle-click paste.
  • Find in the screen and scrollback (Ctrl+Shift+F), 10,000 lines of scrollback.
  • Ctrl+click opens web and mail links, both plain-text addresses and OSC 8 hyperlinks — only http, https, ftp and mailto, never file://.
  • Text reflows like a paragraph when the window is resized.

Compatibility with programs

  • xterm/VT compatible: vim, nvim, htop, lazygit and other full-screen programs work.
  • Mouse reporting (?1000 ?1002 ?1003, SGR ?1006); hold Shift to select text anyway.
  • The kitty keyboard protocol, so programs can tell Ctrl+I from Tab.
  • Sixel images (img2sixel, chafa) that scroll and reflow with the text.
  • Color queries OSC 10/11/12 and OSC 4 (nvim picks its theme from them), clipboard via OSC 52, synchronized output ?2026, DECRQM, origin mode.
  • ConPTY on Windows and a real pty on Linux and macOS.

Fast

  • Only the rows that changed are redrawn — about 20 times less work when typing — and only those rows are copied to the screen. A steady cursor costs nothing while idle.
  • No GPU needed: the software renderer is fast enough and depends on nothing from the system. X11 and Cocoa are loaded at run time, which is how zig cross-compiles the Linux and macOS builds from Windows without an SDK.

Download

Ready-made archives are on the releases page, one per system, with a SHA256SUMS.txt to check them.

ArchiveFor
windows-x64.zipWindows 10/11, most PCs
windows-arm64.zipWindows on ARM
linux-x64, linux-arm64Linux (not yet tested on a real machine)
macos-x64, macos-arm64macOS Intel / Apple Silicon (not yet tested)
linux-armThe shell alone, for older 32-bit Android phones (Termux)

On Windows: unzip, add the folder to your PATH, then type mmc-term for the window or mmc-shell for the shell inside another terminal.

Build it yourself

The only tool needed is zig, used as a C compiler. build cross produces Windows, Linux (static) and macOS programs for x86_64 and aarch64 from any of the three systems; on Linux or macOS a plain make with gcc works too.

Where it stands. Version 0.2.0. Fully tested on Windows 11: it builds with zero warnings under -std=c11 -Wall -Wextra -pedantic, passes all 440 bash compatibility cases and the 290 checks of the terminal core. The Linux and macOS builds compile cleanly but have not been run on real machines yet — bug reports are welcome.

License

mmc-shell is free software under the MIT License. You may use, copy, change and share it, commercially too. The only code not written for it is Sean Barrett's stb_truetype.h (MIT or public domain), and the bundled font keeps its SIL Open Font License.

Marjon Cajocon

Software engineer · Talibon, Bohol, Philippines

I build game engines in C and the apps that ship them. Seven board-game engines, six of them running NNUE neural networks I trained myself, plus a from-scratch LLM engine written in dependency-free C.

Developer
MMC Solo Dev — the name my apps ship under on Google Play and the Microsoft Store
Primary
C — engines, evaluation, search, the LLM stack
Then
Go · Flutter (Dart) · Python · TypeScript / JavaScript
Certification
EDP Specialist — Civil Service, rated 94.65% (80% to pass)
Published
Six apps on the Microsoft Store, five on Google Play
Contact
marjoncajocon08@gmail.com
Code
github.com/marjoncajocon