90 Snippets: Killing processes  πŸ§›

90 Snippets: Killing processes πŸ§›

90 Projects towards mastery - Day 07 πŸš€

Ahoy, fellow developers! Today, as I unravel the essence of Day 07 in my shell scripting voyage, I'm thrilled to share an adventure that's not just about codingβ€”it's a personal tale of empowerment, growth, and mastering the art of process management. Welcome to a realm where every line of code becomes a brushstroke on the canvas of possibilities.

Explore the full code snippet on GitHub

Embracing Proc v1.1

As I embarked on Day 07 of my shell scripting journey, I knew I was about to dive into something personal, something that would empower me to take control of my system like never before. The star of the show was none other than proc v1.1, a script that was poised to be my guide through the realm of process management.

#!/bin/bash

# ... (code snippets)

# Function to print the process list
function print_list() {
    PID_ARRAY=()
    echo -e $BLUE_BOLD"INDEX\tPID\tCMD"$RESET
    for i in "${PROCESS[@]}"; do
        PID_ARRAY+=("$i")
        echo -n -e $CYAN_BOLD"${#PID_ARRAY[@]}\t$RESET"
        echo -e $CYAN_BOLD"$i$RESET" | awk '{print $2, "\t", $11}'
    done
}

# ... (code snippets)

# Clear the screen and display header art
clear
echo -e $RED_BOLD"._____________________________________________."
echo -e $RED_BOLD"|  ┏━┳━┳━┳━┓                                  |"
echo -e $RED_BOLD"|  ┃╋┃╋┃┃┃┏┛ proc v1.1                        |"
echo -e $RED_BOLD"|  ┃┏┫┓┫┃┃┗┓ Process manager                  |"
echo -e $RED_BOLD"|  ┗┛┗┻┻━┻━┛ List and kill processes          |"
echo -e $RED_BOLD"|_____________________________________________|\n"$RESET

A Personal Touch to Process Management

Every line of code in proc v1.1 was a testament to my personal growth. The print_list() function, meticulously crafted, offered a window into the world of processes dancing within my system. With elegance, it presented a symphony of information that was once hidden behind cryptic commands.

# Function to print the process list
function print_list() {
    PID_ARRAY=()
    echo -e $BLUE_BOLD"INDEX\tPID\tCMD"$RESET
    for i in "${PROCESS[@]}"; do
        PID_ARRAY+=("$i")
        echo -n -e $CYAN_BOLD"${#PID_ARRAY[@]}\t$RESET"
        echo -e $CYAN_BOLD"$i$RESET" | awk '{print $2, "\t", $11}'
    done
}

My Journey, My Choices

In the realm of process management, the script didn't just serve a purpose; it became my confidant. The user menu function was a bridge between me and the processes, a way to explore, understand, and, when needed, command.

# Function to print the menu
function print_menu() {
    echo -e $GREEN_BOLD"1. List processes"$RESET
    echo -e $GREEN_BOLD"2. Kill process"$RESET
    echo -e $GREEN_BOLD"3. Exit"$RESET
}

Conclusion: A Personal Milestone

As the sun set on Day 07, I marveled at the journey I had undertaken. proc v1.1 wasn't just a script; it was a companion that stood by me as I ventured into the intricate world of process management. Each choice I made within the menu, and each process I interacted with, was a testament to my growth as a developer.

With a heart full of excitement and a spirit fueled by passion, I can't help but look forward to what lies ahead. As we continue this journey together, remember: every line of code is a step toward empowerment, and every challenge conquered is a milestone on our path to coding mastery.

In code and camaraderie, Your fellow developer

Β