To run WyShell, you have two convenient options:
-
Clone the Repository:
git clone https://github.com/sambuaneesh/wyShell cd wyshell
-
Compile the Shell: Compile the WyShell binary using the following command:
make main
-
Run WyShell: Run WyShell by executing the compiled binary:
./wysh
You can compile and run WyShell in a single command:
make run
To clean up the compiled files and binaries, you can use the following command:
make clean
This command will remove the WyShell executable, the pastevents.txt
file, and any other compiled binaries, ensuring a tidy project structure.
- Welcome to WyShell
The shell prompt is displayed in the following format:
<Username@SystemName:~>
<Username>
: Current username@
: SeparatorSystemName
: System's name~
: Represents the current home directory
Example:
<JohnDoe@SYS:~>
- The shell supports
;
or&
separated lists of commands. - Commands can be separated by random spaces and tabs.
;
is used for sequential commands.&
runs the preceding command in the background.
Example:
<JohnDoe@SYS:~> command1 ; command2 & command3
The warp
command changes the current directory to the specified path and updates the prompt accordingly. It supports symbols like .
(current directory), ..
(parent directory), ~
(home directory), and -
(previous directory).
Example:
<JohnDoe@SYS:~> warp test
/home/johndoe/test
<JohnDoe@SYS:~/test> warp ~
/home/johndoe
<JohnDoe@SYS:~>
The peek
command lists files and directories in the specified directory. It supports -a
(show hidden files) and -l
(display extra information) flags.
Example:
<JohnDoe@SYS:~> peek test
# Output
<JohnDoe@SYS:~> peek -al test
# Output with extra information
The pastevents
command displays the 15 most recent command statements based on certain constraints. It is persistent across different shell runs.
Example:
<JohnDoe@SYS:~> pastevents
# Output the 15 most recent commands
<JohnDoe@SYS:~> pastevents execute 1
# Execute the command at position 1
<JohnDoe@SYS:~> pastevents purge
# Clear all pastevents
Foreground processes wait for completion, and their output is displayed in the terminal.
Example:
<JohnDoe@SYS:~> sleep 5
# Executes sleep command in foreground
Background processes run asynchronously. Their PIDs are displayed in the terminal.
Example:
<JohnDoe@SYS:~> sleep 10 &
# Executes sleep command in the background
The ping
command is used to send signals to processes. Take the pid of a process and send a signal to it corresponding to the provided signal number. Print error “No such process found” if the process with the given pid does not exist.
Example:
<JohnDoe@SYS:~> ping 221 9
Sent signal 9 to process with pid 221
<JohnDoe@SYS:~> ping 430 41
Sent signal 9 to process with pid 430
- Ctrl - C: Interrupts any currently running foreground process by sending it the SIGINT signal. It has no effect if no foreground process is currently running.
- Ctrl - D: Logs out of your shell (after killing all processes) while having no effect on the actual terminal.
- Ctrl - Z: Pushes the (if any) running foreground process to the background and changes its state from “Running” to “Stopped”. It has no effect on the shell if no foreground process is running.
The proclore
command provides information about a process with the given PID.
Example:
<JohnDoe@SYS:~> proclore
# Displays information about the shell
process
<JohnDoe@SYS:~> proclore 301
# Displays information about the process with PID 301
The seek
command searches for a file/directory in the specified target directory. It supports -d
(look for directories only) and -f
(look for files only) flags.
Example:
<JohnDoe@SYS:~> seek newfolder ./doe
# Output matching files/directories in ./doe
The shell supports input/output redirection using >
, >>
, and <
operators.
Example:
<JohnDoe@SYS:~> echo "Hello world" > newfile.txt
# Redirects output to newfile.txt
<JohnDoe@SYS:~> wc < a.txt
# Reads input from a.txt and performs word count
The shell supports piping multiple commands.
Example:
<JohnDoe@SYS:~> echo "Lorem Ipsum" | wc
# Pipes output of echo to wc command
The shell supports redirection along with pipes.
Example:
<JohnDoe@SYS:~> cat < a.txt | wc | sed 's/ //g' | cat > b.txt
# Redirects input from a.txt, pipes through wc and sed, and outputs to b.txt
The shell supports process management commands fg
and bg
.
Example:
<JohnDoe@SYS:~> fg 620
# Brings process with PID 620 to foreground
<JohnDoe@SYS:~> bg 620
# Changes process with PID 620 to background
The neonate
command prints the Process-ID of the most recently created process at specified intervals until the 'x' key is pressed.
Example:
<JohnDoe@SYS:
~> neonate -n 4
# Prints PID every 4 seconds until 'x' is pressed
11810
11811
11811
11812
11813 # Key 'x' is pressed, terminating the printing
The iMan
command fetches man pages from http://man.he.net/ using sockets.
Example:
<JohnDoe@SYS:~> iMan sleep
# Fetches and displays the man page for the 'sleep' command