A minimal, extensible shell implemented in Go, designed for learning, experimentation, and as a foundation for custom scripting environments.
- Language: Go (>=1.18)
- Standard Library: os/exec, bufio, fmt, strings, etc.
- No external dependencies
- REPL loop with customizable prompt
- Built-in commands:
cd,pwd,echo,history,help,exit,export,source,read - Command history with configurable size
- Environment variable management (
export) - Source external script files (
source) - Executes external system commands (e.g.,
ls,cat) - Easily extensible with new built-in commands
git clone <repo-url>
cd go-shell
go run cmd/main.go> pwd
/home/user/go-shell
> echo Hello World
Hello World
> export FOO=bar
> source script.sh
> history
pwd
echo Hello World
export FOO=bar
source script.sh
history
> exit
cmd/main.go # Entry point
internal/shell.go # Shell logic, REPL, built-ins
internal/models.go # Command struct and parsing
internal/ # Other internal logic
- Implement a function with signature:
func(*Shell, []string) error - Add it to the
Builtinsmap inDefaultBuiltins()
Run all tests:
go test ./...