eba49c46bcfd1e27c83ba7dcefe9c98f811ce1fa
- Cross-compiled Go-based shell for Windows (PE32+ executable) - Builtins: cd, pwd, echo, exit, export, source, alias, type - Coreutils: ls, cat, grep, sort, wc, head, find, cp, mv, rm, mkdir, touch, clear - Command chaining: &&, ||, ; - Pipes between builtins and external commands - Variable expansion (, ) and assignment (NAME=VALUE) - Tokenizer with single/double quote handling - Linux and Windows (x86_64) builds via build.sh
bash-for-windows
A fully functional bash shell for Windows, written in Go. Run bash commands and scripts natively on Windows without WSL, Cygwin, or MSYS2.
Features
- Interactive shell with prompt (
bash$) - Built-in commands: cd, pwd, echo, exit, export, source, alias, type
- Built-in coreutils: ls, cat, grep, sort, wc, head, find, cp, mv, rm, mkdir, touch, clear
- Command chaining:
&&,||,; - Pipes:
|between commands - Variable expansion:
$NAME,${NAME} - Variable assignment:
NAME=VALUE command - Single & double quotes:
'literal',"$variable" - Script execution:
bash-windows script.shor-c 'commands' - No dependencies — single
.exefile, runs on any Windows x86-64
Usage
bash-windows # Interactive mode
bash-windows -c 'echo hello'
bash-windows script.sh
Examples
bash$ echo "Hello from bash-for-windows!"
bash$ ls -la
bash$ cd /tmp && pwd
bash$ cat file.txt | grep pattern | wc -l
bash$ name="Luffy" && echo $name
bash$ mkdir -p project/src && touch project/src/main.go
Building
Requires Go 1.21+.
# Linux
./build.sh
# Manual
go build -o build/bash-windows .
# Windows cross-compile
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -o build/bash-windows.exe .
Project Structure
cmd/bash/ - Shell entry point
internal/shell/ - Shell engine (parser, executor, builtins, coreutils)
build/ - Compiled binaries
License
MIT
Languages
Go
92.2%
PowerShell
6.6%
Shell
0.9%
Batchfile
0.3%