A lightweight, cross-platform shell implementation written in Rust. This shell provides basic command-line functionality with built-in commands and support for external commands and command history.
- Cross-platform support (Linux, macOS, Windows)
- Built-in commands implementation
- Command history with persistence
- Environment variable support
- Platform-specific command prompts
- Directory navigation with path normalization
- File operations and text processing commands
cd
- Change directorypwd
- Print working directoryls
- List directory contentsecho
- Display textclear
- Clear screenenv
- Display environment variablescat
- Concatenate and display file contentsgrep
- Search text using patternsfind
- Search for files in directory hierarchyhead
- Output the first part of filestail
- Output the last part of files
Make sure you have Rust and Cargo installed on your system. If not, you can install them from rustup.rs.
- Clone the repository:
git clone https://github.com/miky-rola/shell/
- Build the project:
cargo build --release
- Run the shell:
cargo run --release
src/
├── main.rs # Entry point and shell initialization
├── shell.rs # Core shell implementation
├── command_execution.rs # Core shell implementation
└── shell_type.rs # Shell type enumeration and related functionality
└── builtin.rs # conatins the built in commands
└── utils.rs # utils for shell
Add these dependencies to your Cargo.toml
:
[dependencies]
anyhow = "1.0.68"
bytes = "1.3.0"
thiserror = "1.0.38"
dirs = "5.0"
hostname = "0.3"
which = "4.4"
chrono = "0.4"
filetime = "0.2"
glob = "0.3"
- Start the shell:
cargo run --release
- Use built-in commands:
$ pwd # Print working directory
$ cd ~/Documents # Change directory
$ ls # List files
$ echo Hello, World! # Print text
- Use Up/Down arrow keys to navigate through command history
- Command history is automatically saved and persists between sessions
- History file is stored in your home directory as
.shell_history
(Unix) or.shell_history.txt
(Windows)
user@hostname:~$ ls
Documents Downloads Pictures
user@hostname:~$ cd Documents
user@hostname:~/Documents$ pwd
/home/user/Documents
user@hostname:~/Documents$ echo "Hello from Rust Shell!"
Hello from Rust Shell!
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
- Limited shell scripting capabilities
- Basic command line editing features
- No pipeline operations support yet
- Limited wildcard expansion
- Add support for command pipelines (
|
) - Implement input/output redirection
- Add shell scripting capabilities
- Implement job control
- Add more built-in commands
- Improve tab completion with context awareness
- Add alias support
- Implement environment variable expansion
- The Rust community for excellent documentation and crates
- Various Unix shell implementations that inspired this project