Skip to content

Latest commit

 

History

30 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MyTerm: A Custom X11 Terminal

MyTerm is a custom terminal application built in C++ using the X11 library.

It functions as a standalone shell, supporting multiple tabs, command pipelines, I/O redirection, and advanced features like multiWatch and searchable history.


1. Dependencies (Linux)

This project is designed for Linux. You will need g++ and the X11 development libraries.

On Debian-based systems (like Ubuntu), you can install all requirements with:

sudo apt-get update
sudo apt-get install build-essential libx11-dev

2. How to Compile

A Makefile is provided. To compile the project, navigate to the root directory and run:

make

This will use g++ to compile all source files and create a single executable file in the root directory named MyTerminal.


3. How to Run

After compiling, you can run the terminal with:

./MyTerminal

Alternatively, you can use the Makefile's run target:

make run

To remove the compiled executable, run:

make clean

4. How to Use (Features & Examples)

MyTerm functions like a standard bash shell. Here are the supported features and their syntax.

GUI and Navigation

  • New Tab: Ctrl + T
  • Switch Tab: Ctrl + Tab
  • Line Navigation:
    • Ctrl + A: Move cursor to the start of the line
    • Ctrl + E: Move cursor to the end of the line
  • Autocomplete:
    • Press [Tab] to autocomplete a filename.
    • If there are multiple options, it will complete to the longest common prefix.
    • Press Tab again to see a numbered list of choices.

Shell Commands & Syntax

  • External Commands: Any standard Linux command works.
ls -l /home
gcc my_program.c -o my_program
./my_program
  • Multiline Input:
    You can use quotes or the \ character to write commands that span multiple lines.
    A > continuation prompt will appear.
echo "This is a
multi-line string"
  • I/O Redirection: Supports <, >, and >>.
# Input from a file
sort < unsorted_names.txt

# Output to a file (overwrite)
ls > file_list.txt

# Output to a file (append)
echo "New log line" >> main.log

# Combination
./a.out < input.txt > output.txt
  • Pipes: Chain multiple commands together.
cat /var/log/syslog | grep "error" | wc -l
  • multiWatch Command: (Project-specific feature)
    Executes multiple commands in parallel and prints their output every 2 seconds with a timestamp.
multiWatch ["ls -l | wc -l", "date", "echo 'hello'"]

Press Ctrl + C to stop multiWatch.


History and Interrupts

  • Command History:

    • history: Shows the last 1000 commands.
  • Searchable History:

    • Ctrl + R: Enter "search mode".
    • Type your search term (e.g., grep) and press Enter.
    • Finds the most recent command that either matches exactly or has the longest common substring with your term.
  • Interrupts:

    • Ctrl + C: Sends a SIGINT signal to terminate the running command.
    • Ctrl + Z: Moves the running command to the background and gives you a new prompt.
      The command's output will continue to print to the screen.

5. Notes

  • Each tab runs in a separate shell process for true parallelism.
  • The GUI uses an asynchronous event loop with select() to stay responsive.
  • Unicode input and output are supported using setlocale(LC_ALL, "") and X11 UTF-8 handling.
  • All communication between frontend and backend happens via pipes.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages