rsh
(Rust Shell) is a lightweight, customizable command-line shell written in Rust. It provides basic shell functionalities like executing commands, autocompletion for commands and paths, and history-based suggestions. Inspired by the functionality of zsh
, rsh
is designed to be a starting point for building a more advanced and feature-rich shell.
- Command Execution: Run any command available in your system's
PATH
. - Built-In Commands:
cd
: Change directories.exit
: Exit the shell.
- Autocomplete:
- Command suggestions from system
PATH
. - File and directory path suggestions.
- History-based suggestions for previously entered commands.
- Command suggestions from system
- Graceful Exit:
- Handles
Ctrl+C
andCtrl+D
to terminate the shell cleanly.
- Handles
- Rust installed on your system.
git clone https://github.com/yourusername/rsh.git
cd rsh
cargo build --release
cargo run
cargo run
- Run a Command:
rsh> ls
- Change Directory:
rsh> cd /path/to/directory
- Exit the Shell:
- Type
exit
, or - Press
Ctrl+C
orCtrl+D
.
- Type
- Press
Tab
to autocomplete commands, paths, or history:- Command Suggestions:
rsh> ls [Tab]
- Path Suggestions:
Completes to:
rsh> cd /ho[Tab]
rsh> cd /home/
- History Suggestions:
Completes to:
rsh> echo hello rsh> ec[Tab]
rsh> echo hello
- Command Suggestions:
rsh/
├── src/
│ ├── main.rs # Main entry point
│ ├── shell/
│ │ ├── mod.rs # Shell module
│ │ ├── commands.rs # Command execution logic
│ │ ├── completer.rs # Autocompletion logic
│ │ ├── prompt.rs # (Optional) Prompt display logic
│ │ ├── input.rs # (Optional) Input handling logic
│ └── utils/
│ ├── mod.rs # Utility functions
-
Add New Built-In Commands:
- Modify
main.rs
to detect the new command. - Add the corresponding functionality in
shell/commands.rs
.
- Modify
-
Extend Autocompletion:
- Update
FilePathAndCommandCompleter
inshell/completer.rs
.
- Update
- Command Aliases: Allow users to define and use aliases for commands.
- Scripting Support: Execute scripts directly from the shell.
- Configuration File: Allow customization via a
.rshrc
file. - Colored Prompts and Output: Add dynamic and colorful prompts and outputs.
Contributions are welcome! Please open issues or submit pull requests on the GitHub repository.
This project is licensed under the MIT License. See the LICENSE
file for details.
- Inspired by the simplicity and functionality of
zsh
andbash
. - Built with love using Rust.