Kai Shell is a simple Unix shell implementation in C, offering basic command-line functionalities similar to popular Unix shells like Bash. It supports executing commands, built-in commands like cd
, help
, exit
, and additional custom commands hello
and date
.
- Basic Command Execution: Run commands like in a typical shell.
- Built-in Commands: Includes
cd
(change directory),help
(display help message),exit
(terminate the shell),hello
(custom greeting), anddate
(display current date and time). - Command Line Editing: Basic line editing capabilities such as reading and splitting input into tokens.
- Process Management: Launch external programs and wait for them to terminate using
fork
,execvp
, andwaitpid
.
This project is based on the tutorial by Stephen Brennan on how to write a shell in C. The initial structure and concepts were adapted from the LSH (Libstephen SHell) repository and the accompanying tutorial "Write a Shell in C" by Stephen Brennan. Thank you, Stephen Brennan, for providing such a comprehensive resource!
- GCC (GNU Compiler Collection) or another C compiler that supports C11.
- Linux or macOS environment (though it should work on other Unix-like systems as well).
-
Clone the repository:
git clone https://github.com/suswagatam-rong/kai-shell.git cd kai-shell
-
Compile the project:
gcc -o kai-shell main.c kai_shell.c
To start the Kai Shell, simply execute the compiled binary:
./kai-shell
You should see the shell prompt (kai-shell>
), where you can enter commands and interact with the shell.
- Executing Commands: Enter any system command (e.g.,
ls
,pwd
). - Built-in Commands:
cd [directory]
: Change current directory.help
: Display list of available commands.exit
: Exit the shell.hello
: Print a welcome message.date
: Display current date and time.
kai-shell> hello
Hello! Welcome to Kai's Custom Shell!
kai-shell> date
Current date and time: Mon Jun 17 12:34:56 2024
kai-shell> ls
Desktop Documents Downloads Music Pictures Videos
kai-shell> cd Documents
kai-shell> pwd
/home/user/Documents
Contributions are welcome! Feel free to open issues for bugs, feature requests, or submit pull requests with improvements.
This project is licensed under the Unlicense. See the UNLICENSE file for more details.