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.
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-devA Makefile is provided. To compile the project, navigate to the root directory and run:
makeThis will use g++ to compile all source files and create a single executable file in the root directory named MyTerminal.
After compiling, you can run the terminal with:
./MyTerminalAlternatively, you can use the Makefile's run target:
make runTo remove the compiled executable, run:
make cleanMyTerm functions like a standard bash shell. Here are the supported features and their syntax.
- New Tab:
Ctrl + T - Switch Tab:
Ctrl + Tab - Line Navigation:
Ctrl + A: Move cursor to the start of the lineCtrl + 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.
- Press
- 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 -lmultiWatchCommand: (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.
-
Command History:
history: Shows the last 1000 commands.
-
Searchable History:
Ctrl + R: Enter "search mode".- Type your search term (e.g.,
grep) and pressEnter. - Finds the most recent command that either matches exactly or has the longest common substring with your term.
-
Interrupts:
Ctrl + C: Sends aSIGINTsignal 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.
- 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.