Welcome to csh, a custom shell program implemented in C! ๐
- Command Execution ๐ ๏ธ
- Supports executing built-in and external commands.
- Redirection ๐
- Input and output redirection for commands.
- Alias Management ๐ท๏ธ
- Create, view, and manage command aliases.
- Modular Design ๐งฉ
- Organized codebase for better readability and maintainability.
- Environment Variable Initialization ๐
- Automatically sets the
SHELL
environment variable to the shell's executable path.
- Automatically sets the
- Configuration File Support ๐
- Reads and executes commands from
~/.cshrc
configuration file on startup. - Creates a default
~/.cshrc
if it doesn't exist.
- Reads and executes commands from
- Comment Handling ๐
- Skips lines starting with
#
in the configuration file.
- Skips lines starting with
- Cross-Platform Compatibility ๐
- Supports macOS (using
_NSGetExecutablePath
) and Linux (using/proc/self/exe
).
- Supports macOS (using
- Configuration Appearance
- Refactor main.c
- Tab autocompletion
- Up-Down history searching
- GCC (GNU Compiler Collection)
-
Clone the repository:
git clone https://github.com/yourusername/csh.git cd csh
-
Build the project using
make
:make
-
Run the shell:
./csh
-
Or install the shell:
sudo make install
To clean up the generated files:
make clean
-
Interactive Mode: Simply run
./csh
to start the shell in interactive mode. -
Batch Mode: Provide a script file as an argument to execute commands from the file:
./csh script.txt
-
Running a command:
ls -l
-
Redirecting output:
ls -l > output.txt
-
Creating an alias:
alias ll='ls -l'
main.c
: Main entry point of the shell program.commands.c
: Implementation of command execution functions.redirection.c
: Implementation of input/output redirection.alias.c
: Implementation of alias management.utils.c
: Utility functions.fdwrite.c
: Implementation of file descriptor writing functions.commands.h
,redirection.h
,alias.h
,utils.h
,fdwrite.h
: Header files declaring functions and structures.
Contributions are welcome! Please fork the repository and submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.
Thanks to all the contributors and open-source projects that made this possible.
Happy coding! ๐ป