This project is a custom shell implementation written in C that can handle most of the commands that bash can. It supports piping and redirection, environment variables, signal handling, and more.
- Run any command that can be run in bash
- Handle piping and redirection of input and output
- Manage environment variables
- Handle signals like SIGINT (Ctrl-C) and SIGTSTP (Ctrl-Z)
- Use terminal capabilities to display colored output and navigate through command history
- Autocomplete commands using the tab key
- Run commands in the background using the "&" symbol
To get started with this project, clone the repository to your local machine and navigate to the project directory. Compile the code by running the make
command in the terminal.
Once the code is compiled, run the shell executable using the following command:
$ ./shell
This will start the shell and you can start entering commands.
This shell works just like any other shell. You can run any command that can be run in bash, including pipes and redirection.
To pipe the output of one command to another, use the "|" symbol. For example, to list all the files in the current directory and then sort them alphabetically, you can use the following command:
$ ls -la | sort
To redirect the output of a command to a file, use the ">" symbol. For example, to save the output of the "ls" command to a file called "files.txt", you can use the following command:
$ ls > files.txt
To append the output of a command to a file, use the ">>" symbol. For example, to append the output of the "ls" command to a file called "files.txt", you can use the following command:
$ ls >> files.txt
To set an environment variable, use the "export" command. For example, to set the variable "MYVAR" to the value "hello", you can use the following command:
$ export MYVAR=hello
To see a list of all environment variables, use the "env" command. For example:
$ env
This shell handles signals like SIGINT (Ctrl-C) and SIGTSTP (Ctrl-Z). To interrupt a running command, press Ctrl-C. To pause a running command, press Ctrl-Z.
To autocomplete commands, press the tab key. The shell will attempt to complete the command based on the characters you've typed so far.
To run a command in the background, use the "&" symbol at the end of the command. For example:
$ sleep 10 &
This will run the "sleep 10" command in the background, allowing you to continue entering commands in the shell.
If you have any ideas for new features or improvements to existing ones, feel free to submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.