Skip to content

my c++ implementation of a linux shell with core shell functionalities, including command parsing, process creation, signal handling and shell built-ins.

License

Notifications You must be signed in to change notification settings

isaiah76/linux-shell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

linux-shell

A C++ implementation of a Linux shell that is lightweight and customizable. linux-shell provides a familiar command-line interface with support for command history, aliases, and common built-in commands.

Features

  • Command Execution: Run any standard Linux programs and commands
  • Built-in Commands:
    • cd: Change directory
    • pwd: Print working directory
    • echo: Display text
    • history: View command history
    • alias/unalias: Create and manage command aliases
    • exit: Exit the shell
  • Command History: Persistent history between sessions with support for history navigation
  • Tab Completion: File and command tab completion
  • Aliases: Define custom command shortcuts that persist between sessions
  • Signal Handling: Properly handles Ctrl+C (SIGINT) and Ctrl+Z (SIGTSTP)
  • Multiline Commands: Support for command continuation with backslash

Installation

Prerequisites

  • A C++ compiler with C++11 support
  • CMake (version 3.10 or later)
  • Readline development library

On Debian/Ubuntu:

sudo apt-get install build-essential cmake libreadline-dev

On Arch Linux:

sudo pacman -S base-devel cmake readline

On Red Hat/Fedora:

sudo dnf install gcc-c++ cmake readline-devel

Building and Installing

Clone the repository:

git clone https://github.com/isaiah76/linux-shell.git
cd linux-shell

You have two options to build and install:

Option 1: Automated Build/Installation Script

  1. Make the script executable:
chmod +x build_install.sh
  1. Run the script:
./build_install.sh

Option 2: Manual Build with CMake

  1. Create a build directory, configure and build the project:
mkdir build
cd build
cmake ..
make
  1. To install the shell system-wide (the binary will be installed to /usr/local/bin):
sudo make install

Usage

After installation, launch the shell by typing:

linux-shell

Command history

Command history is automatically saved to ~/.linux_shell_history and loaded when the shell starts.

  • Use the up and down arrow keys to navigate through command history.
  • View history with the history command:
history      # Show all history
history 10   # Show the last 10 commands

Aliases

Create an alias:

alias ll='ls -la'
alias gs='git status'

View all aliases:

alias ll='ls -la'
alias gs='git status'

View a specific alias:

alias ll

Remove an alias:

unalias ll

Aliases are automatically saved to ~/.linux_shell_aliases and loaded when the shell starts.

About

my c++ implementation of a linux shell with core shell functionalities, including command parsing, process creation, signal handling and shell built-ins.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published