A lightweight, feature-rich Unix shell written in C++17. Designed to be clean, responsive, and independent of heavy terminal dependency libraries (like readline), using direct POSIX system APIs and terminal raw mode configuration.
- Tab Completion: Auto-complete command names (built-ins & executables in
$PATH) and file/folder paths. Directory completions automatically append a trailing slash/. Supports double-tab listing of matches. - Command History: Navigate through previous commands using the Up and Down arrow keys. Unsaved current drafts are preserved when navigating.
- Cursor Control: Move the cursor back and forth using Left and Right arrows, or jump to boundaries using Home and End.
- Editing Tools: Modify inputs in place using Backspace and Delete keys.
- Ctrl+C / Ctrl+D Support: Pressing
Ctrl+Ccancels the current input line without terminating the shell. PressingCtrl+Don an empty line cleanly exits the shell.
- Pipelines (
|): Pipe the output of one command to another (e.g.,uptime | grep uptime). - File Redirection: Redirect standard input using
<and standard output using>(overwrite) or>>(append). (e.g.,echo "output" > log.txt). - Wildcard Globbing (
*): Expands file glob patterns automatically (e.g.,ls header/*.horrm *.o).
- Raw terminal mode is disabled automatically before child processes execute, so full-screen applications (like
nano,vim, or interactive commands likesudo) function perfectly. - Parent process ignores
SIGINT(Ctrl+C) while waiting for children, allowing child termination without exiting the shell. - Terminal configurations are safely restored to cooked mode upon exits or abnormal terminations.
- Quote Awareness: Handles arguments wrapped in single quotes
'...'or double quotes"..."(e.g.mkdir "my directory"). - Escape Sequences: Supports backslash escapes
\for paths with special characters. - Tilde Expansion: Automatically expands
~to the user's home directory. - Environment Variables: Automatically expands
$VARexpressions (like$USERor$HOME) in commands or double quotes.
In addition to running external programs via execvp, mash implements the following built-ins directly:
- Navigation & Info:
cd,pwd,ls(colorized table-format output),which,uptime,free. - File & Directory Ops:
mkdir,rm,touch,cp,mv,cat,head,tail,find(recursive name search). - Ownership & Permissions:
chmod,chown,chgrp. - System Utilities:
echo,date,uname,whoami,version,help,history,clear. - Environment & Aliases:
env,export,alias,unalias,source(executes shell script files).
- A compiler with support for C++17 (e.g.,
g++8+ orclang++). - A POSIX-compliant environment (Linux or macOS).
You can download the compiled binaries directly from the Releases page of this repository:
- Linux (amd64):
mash-linux-amd64 - macOS (Universal - Intel & Apple Silicon):
mash-macos
After downloading, grant execution permissions and run:
chmod +x mash-linux-amd64 # or mash-macos
./mash-linux-amd64Compile the shell executable using the provided build script:
./build.shLaunch the shell:
./mashThis project is licensed under the MIT License. See the LICENSE file for details.