Code Monkey home page Code Monkey logo

csh's Introduction

csh - C Shell

Welcome to csh, a custom shell program implemented in C! ๐ŸŽ‰

Features โœจ

  • 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.
  • Configuration File Support ๐Ÿ“œ
    • Reads and executes commands from ~/.cshrc configuration file on startup.
    • Creates a default ~/.cshrc if it doesn't exist.
  • Comment Handling ๐Ÿ“
    • Skips lines starting with # in the configuration file.
  • Cross-Platform Compatibility ๐ŸŒ
    • Supports macOS (using _NSGetExecutablePath) and Linux (using /proc/self/exe).

Next Step

  • Configuration Appearance
  • Refactor main.c
  • Tab autocompletion
  • Up-Down history searching

Getting Started ๐Ÿš€

Prerequisites

  • GCC (GNU Compiler Collection)

Building the Project

  1. Clone the repository:

    git clone https://github.com/yourusername/csh.git
    cd csh
  2. Build the project using make:

    make
  3. Run the shell:

    ./csh
  4. Or install the shell:

    sudo make install

Cleaning Up

To clean up the generated files:

make clean

Usage ๐Ÿ“

  • 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

Example Commands

  • Running a command:

    ls -l
  • Redirecting output:

    ls -l > output.txt
  • Creating an alias:

    alias ll='ls -l'

File Structure ๐Ÿ“

  • 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.

Contributing ๐Ÿค

Contributions are welcome! Please fork the repository and submit a pull request.

License ๐Ÿ“„

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgements ๐Ÿ™

Thanks to all the contributors and open-source projects that made this possible.


Happy coding! ๐Ÿ’ป

csh's People

Contributors

sma1lboy avatar

Stargazers

็™ฝ้ฉฌ้ž้ฉฌ avatar WangYiChen avatar tim avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.