MyShell is a custom Unix-like command-line interpreter (shell) written in C. It supports standard command execution, command history, piping, input/output redirection, and includes advanced features like Tab Completion and a built-in Arithmetic Evaluator.
MyShell is designed to be a powerful and user-friendly alternative shell, incorporating features typically found in modern shells:
- Command Execution: Executes external programs and system commands.
- Piping (
|): Supports connecting the output of one command to the input of another. - Input/Output Redirection (
<,>): Allows redirecting command input from a file or output to a file.
- Tab Completion: Provides auto-completion for both external commands (by searching the
$PATH) and local files/directories.- Pressing
TABonce will complete a single match or, if multiple matches exist, pressingTABagain will list all possibilities.
- Pressing
- Command History: Stores and manages command history, allowing easy navigation2].
- Use the
UPandDOWNarrow keys to scroll through previously executed commands. - History is persisted between sessions by saving it to a file at
~/.myshell_history.
- Use the
- Built-in Calculator: MyShell can evaluate arithmetic expressions directly typed into the prompt.
- Supports integers and floating-point numbers (printed to two decimal places if not a whole number).
- Supported operators include addition (
+), subtraction (-), multiplication (*), division (/), modulo (%), and exponentiation (^). - Supports parentheses for defining order of operations35].
MyShell includes its own set of essential built-in commands for core shell functionality:
| Command | Description | Source |
|---|---|---|
cd <directory> |
Changes the current working directory. | Built-in |
exit |
Closes MyShell and returns to the calling shell[cite: 12]. | Built-in |
help |
Displays this comprehensive help message listing all features and built-in commands[cite: 13, 14]. | Built-in |
The installation process compiles the MyShell source code from the GitHub repository and installs the resulting binary to /usr/local/bin. You must have git and gcc installed.
git: For cloning the repository.gcc(GNU Compiler Collection): For compiling the C source code.sudoprivileges: Required to install the binary to/usr/local/bin.
- Download the Installation Script:
wget https://raw.githubusercontent.com/Bimbok/myshell/main/install.sh -O install.sh chmod +x install.sh
- Run the Installer with
sudo:This script will perform the following actions:sudo ./install.sh
- Check for
sudoprivileges. - Clone the source code from
https://github.com/Bimbok/myshell.gitinto a temporary directory (/tmp/myshell-install). - Compile
myshell.cusinggcc. - Copy the compiled binary (
myshell) to/usr/local/bin. - Clean up the temporary files.
- Check for
After installation, you can run MyShell by simply typing:
myshellThe uninstallation script removes the binary and cleans up the system-wide configuration, but intentionally preserves your personal history file for safety.
- Download the Uninstallation Script:
wget https://raw.githubusercontent.com/Bimbok/myshell/main/uninstall.sh -O uninstall.sh chmod +x uninstall.sh
- Run the Uninstaller with
sudo:This script will perform the following actions:sudo ./uninstall.sh
- Check for
sudoprivileges. - Check Login Shell: It checks if the user running the script is currently using MyShell as their login shell. If so, it issues a critical warning and prompts for confirmation to prevent the user from being locked out of their system.
- Remove the MyShell binary from
/usr/local/bin/myshell. - Remove the MyShell path (
/usr/local/bin/myshell) from the system-wide/etc/shellsfile, creating a backup first. - Inform the user that the personal history file (
~/.myshell_history) was not removed.
- Check for
If you wish to completely remove all traces of MyShell, manually delete the history file:
rm -f ~/.myshell_historyThe install.sh script supports a specific parameter for system configuration:
| Parameter | What it Does |
|---|---|
--set-login |
This option only modifies the system shell list[cite: 216]. It adds the MyShell binary path (/usr/local/bin/myshell) to the /etc/shells file. |
| No Parameter | Runs the primary installation process: clones, compiles, and installs the binary to /usr/local/bin. |
Run the command below after the binary has been successfully installed. This step is necessary if you intend to use MyShell as your default login shell (e.g., via chsh):
sudo ./install.sh --set-loginTo then make MyShell your default login shell, use chsh:
chsh -s /usr/local/bin/myshellMyShell operates like any standard Unix shell.
Type the command and its arguments, then press Enter:
myshell $ ls -l | grep txt > output.txtType the full expression and press Enter. MyShell detects the arithmetic pattern and evaluates it instead of executing a program[cite: 186].
myshell $ 10 + 5 * (8/4)
30
myshell $ 2^8 - 1
255-
Command Completion: Type the start of a command and press
TAB:myshell $ help # Press TAB after 'h'
(This would complete to
helpor show options likehistory, etc., if they existed.) -
File/Directory Completion: Type the start of a file path (or a path starting with
./,/, or~) and pressTAB[cite: 103].myshell $ cat outpu # Press TAB after 'outpu' to complete to 'output.txt'