A lightweight shell implementation written in Go for educational purposes.
gosh is a simple shell that provides basic file system operations and system commands. It works on Unix-like systems and Windows 10 or higher.
Note: This project is built for learning purposes and is not intended for production use.
- Interactive command-line interface
- Built-in help system with command documentation
- Support for command flags and arguments
- Cross-platform support
- Go 1.24.0 or higher
- Windows 10 or higher (for Windows users)
- Clone the repository:
git clone https://github.com/Jamescog/gosh.git
cd gosh- Build the binary:
go build- Run the shell:
./goshgo install github.com/Jamescog/gosh@latestLaunch the shell by running the compiled binary:
./goshYou will be greeted with the gosh prompt:
-> gosh:
Type commands followed by their arguments and press Enter to execute them.
To see all available commands:
helpTo get detailed information about a specific command:
help <command>Example:
help lsList directory contents.
Usage: ls [OPTIONS] [PATH]
Options:
-a- Show all files including hidden files-l- Use long listing format-h- Human-readable file sizes (use with-l)-lh- Long format with human-readable sizes
Examples:
ls
ls -a
ls -l
ls -lh /homeChange the current working directory.
Usage: cd DIRECTORY
Examples:
cd /home
cd ..
cd ~Print the current working directory.
Usage: pwd
Example:
pwdCreate directories.
Usage: mkdir [OPTIONS] DIRECTORY...
Options:
-p- Create parent directories as needed-v- Verbose output-m MODE- Set file permissions (default: 0755)
Examples:
mkdir newdir
mkdir -p dir1/dir2/dir3
mkdir -v newdir
mkdir -m 0700 privateCreate empty files or update file timestamps.
Usage: touch FILE...
Examples:
touch file.txt
touch file1.txt file2.txtClear the terminal screen.
Usage: clear
Display help information about commands.
Usage: help [COMMAND]
Examples:
help
help lsExit the shell.
Usage: exit
gosh/
├── main.go # Application entry point
├── go.mod # Go module definition
├── commands/ # Command implementations
│ ├── base.go # Command interface definition
│ ├── registry.go # Command registry system
│ ├── cd.go # Change directory command
│ ├── clear.go # Clear screen command
│ ├── exit.go # Exit shell command
│ ├── help.go # Help command
│ ├── ls.go # List directory command
│ ├── mkdir.go # Make directory command
│ ├── pwd.go # Print working directory command
│ └── touch.go # Touch file command
└── utils/ # Utility functions
├── color_other.go # Color support for Unix-like systems
├── color_windows.go # Color support for Windows
├── file_uitls.go # File utility functions
├── parse_command.go # Command parsing logic
└── pretty_print.go # Output formatting utilities
# Linux
GOOS=linux GOARCH=amd64 go build -o gosh-linux
# macOS
GOOS=darwin GOARCH=amd64 go build -o gosh-darwin
# Windows
GOOS=windows GOARCH=amd64 go build -o gosh.exeThis project is available under the MIT License.
Jamescog
Built with Go's standard library and minimal external dependencies for maximum portability and performance.