Add ccecho feature, and modified the main script

This commit is contained in:
2025-06-13 14:02:04 +01:00
parent a736a3ae27
commit 4762d195b7
5 changed files with 389 additions and 270 deletions

View File

@@ -11,6 +11,7 @@ This project provides a modular system for managing Bash scripts within the .bas
- **Automatic Directory Structure**: The installer automatically creates directories for managing available, enabled, removed, and required scripts. - **Automatic Directory Structure**: The installer automatically creates directories for managing available, enabled, removed, and required scripts.
- **Customizable Script Templates**: When creating a new script, a template with placeholders for options, variables, functions, and execution logic is provided. - **Customizable Script Templates**: When creating a new script, a template with placeholders for options, variables, functions, and execution logic is provided.
- **Easy Integration**: Automatically integrate with your existing .bashrc setup. - **Easy Integration**: Automatically integrate with your existing .bashrc setup.
- **Colorful Echo (`ccecho`)**: Print colored and styled messages for better terminal output, ( usable even outside of the brc-script environment )
## Directory Structure ## Directory Structure
@@ -23,14 +24,13 @@ After installation, the system uses the following directory layout to manage scr
- `scripts-enabled/`: Symbolic links to enabled scripts. - `scripts-enabled/`: Symbolic links to enabled scripts.
- `scripts-needed/`: Essential scripts required for the system to work. - `scripts-needed/`: Essential scripts required for the system to work.
- `brc-script.sh` - `brc-script.sh`
- `ccecho.sh`
- `scripts-removed/`: Backup of removed scripts, timestamped. - `scripts-removed/`: Backup of removed scripts, timestamped.
## Installation ## Installation
### Automated Installation ### Automated Installation
To install the system automatically, follow these steps:
1. Clone the repository: 1. Clone the repository:
```bash ```bash
git clone https://github.com/your-repo/modular-bashrc-manager.git git clone https://github.com/your-repo/modular-bashrc-manager.git
@@ -46,20 +46,19 @@ To install the system automatically, follow these steps:
The installer will: The installer will:
- Create the necessary directory structure: `scripts-needed`, `scripts-enabled`, `scripts-available`, and `scripts-removed`. - Create the necessary directory structure: `scripts-needed`, `scripts-enabled`, `scripts-available`, and `scripts-removed`.
- Append the required configuration to your .bashrc file. - Append the required configuration to your .bashrc file.
- Copy the main `brc-script.sh` script to `scripts-needed/`. - Copy the main `brc-script.sh` script and `ccecho.sh` to `scripts-needed/`.
After the installation completes, restart your shell or reload the .bashrc file by running: Reload the `.bashrc` file by running:
```bash ```bash
source ~/.bashrc source ~/.bashrc
``` ```
### Manual Installation ### Manual Installation
If you prefer a manual installation process, follow these steps: 1. Copy the `brc-script.sh` and `ccecho.sh` files to the `~/.bashrc.d/scripts-needed/` folder:
1. Copy the `brc-script.sh` file to the `~/.bashrc.d/scripts-needed/` folder:
```bash ```bash
cp brc-script.sh ~/.bashrc.d/scripts-needed/ cp brc-script.sh ccecho.sh ~/.bashrc.d/scripts-needed/
chmod 750 ~/.bashrc.d/scripts-needed/brc-script.sh chmod 750 ~/.bashrc.d/scripts-needed/brc-script.sh ~/.bashrc.d/scripts-needed/ccecho.sh
``` ```
2. Append the following lines to your `.bashrc` file: 2. Append the following lines to your `.bashrc` file:
@@ -82,7 +81,7 @@ If you prefer a manual installation process, follow these steps:
mkdir -p ~/.bashrc.d/scripts-needed ~/.bashrc.d/scripts-enabled ~/.bashrc.d/scripts-available ~/.bashrc.d/scripts-removed mkdir -p ~/.bashrc.d/scripts-needed ~/.bashrc.d/scripts-enabled ~/.bashrc.d/scripts-available ~/.bashrc.d/scripts-removed
``` ```
4. Restart your shell or source `.bashrc`: 4. Reload `.bashrc`:
```bash ```bash
source ~/.bashrc source ~/.bashrc
``` ```
@@ -125,6 +124,37 @@ The `brc-script.sh` script provides a series of commands to manage your .bashrc
brc-script -r brc-script -r
``` ```
## Extra Utilities
### `ccecho`: Colorful Echo for Enhanced Output
The project includes a utility script `ccecho.sh` located in `scripts-needed/`, which defines a function `ccecho`. This command allows you to print styled and colored messages to the terminal.
#### Usage
```bash
ccecho -t green -b black -s bold "Success!"
ccecho -t red -s underline "Error!"
ccecho "Normal message without styling"
```
#### Available Text Colors
`black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`, `bblack`, `bred`, `bgreen`, `byellow`, `bblue`, `bmagenta`, `bcyan`, `bwhite`
#### Background Colors
Same as above, applied with `-b`
#### Styles
`bold`, `dim`, `italic`, `underline`, `blink`, `reverse`, `hidden`, `strike`
#### Make `ccecho` Globally Available
If you'd like to use `ccecho` in other terminal sessions or scripts, you can source it in your `.bashrc`:
```bash
source ~/.bashrc.d/scripts-needed/ccecho.sh
```
## Why Use This System? ## Why Use This System?
Managing a large .bashrc file can become unmanageable, especially when adding multiple custom commands or functions. This system offers a structured approach to handle modular scripts, making it easier to enable or disable specific configurations without manually editing the .bashrc file each time. Managing a large .bashrc file can become unmanageable, especially when adding multiple custom commands or functions. This system offers a structured approach to handle modular scripts, making it easier to enable or disable specific configurations without manually editing the .bashrc file each time.

66
README.md.backup Executable file → Normal file
View File

@@ -1,5 +1,6 @@
# Modular Bashrc Manager # Modular Bashrc Manager
A simple, modular, and clean way to manage your .bashrc file in Linux. ### A simple, modular, and clean way to manage your .bashrc file in Linux.
---
This project provides a modular system for managing Bash scripts within the .bashrc environment. It allows users to easily enable, disable, create, and manage custom scripts through a well-structured directory layout, making the .bashrc configuration cleaner and easier to maintain. This project provides a modular system for managing Bash scripts within the .bashrc environment. It allows users to easily enable, disable, create, and manage custom scripts through a well-structured directory layout, making the .bashrc configuration cleaner and easier to maintain.
@@ -10,6 +11,7 @@ This project provides a modular system for managing Bash scripts within the .bas
- **Automatic Directory Structure**: The installer automatically creates directories for managing available, enabled, removed, and required scripts. - **Automatic Directory Structure**: The installer automatically creates directories for managing available, enabled, removed, and required scripts.
- **Customizable Script Templates**: When creating a new script, a template with placeholders for options, variables, functions, and execution logic is provided. - **Customizable Script Templates**: When creating a new script, a template with placeholders for options, variables, functions, and execution logic is provided.
- **Easy Integration**: Automatically integrate with your existing .bashrc setup. - **Easy Integration**: Automatically integrate with your existing .bashrc setup.
- **Colorful Echo (`ccecho`)**: Print colored and styled messages for better terminal output, ( usable even outside of the brc-script environment )
## Directory Structure ## Directory Structure
@@ -18,19 +20,17 @@ After installation, the system uses the following directory layout to manage scr
- `~/.bashrc.d/`: Main directory for managing Bash scripts. - `~/.bashrc.d/`: Main directory for managing Bash scripts.
- `installer/`: Contains the installer and base script. - `installer/`: Contains the installer and base script.
- `brc-script-install.sh` - `brc-script-install.sh`
- `brc-script.sh`
- `scripts-available/`: Scripts available to be enabled. - `scripts-available/`: Scripts available to be enabled.
- `scripts-enabled/`: Symbolic links to enabled scripts. - `scripts-enabled/`: Symbolic links to enabled scripts.
- `scripts-needed/`: Essential scripts required for the system to work. - `scripts-needed/`: Essential scripts required for the system to work.
- `brc-script.sh` - `brc-script.sh`
- `ccecho.sh`
- `scripts-removed/`: Backup of removed scripts, timestamped. - `scripts-removed/`: Backup of removed scripts, timestamped.
## Installation ## Installation
### Automated Installation ### Automated Installation
To install the system automatically, follow these steps:
1. Clone the repository: 1. Clone the repository:
```bash ```bash
git clone https://github.com/your-repo/modular-bashrc-manager.git git clone https://github.com/your-repo/modular-bashrc-manager.git
@@ -46,20 +46,19 @@ To install the system automatically, follow these steps:
The installer will: The installer will:
- Create the necessary directory structure: `scripts-needed`, `scripts-enabled`, `scripts-available`, and `scripts-removed`. - Create the necessary directory structure: `scripts-needed`, `scripts-enabled`, `scripts-available`, and `scripts-removed`.
- Append the required configuration to your .bashrc file. - Append the required configuration to your .bashrc file.
- Copy the main `brc-script.sh` script to `scripts-needed/`. - Copy the main `brc-script.sh` script and `ccecho.sh` to `scripts-needed/`.
After the installation completes, restart your shell or reload the .bashrc file by running: Reload the `.bashrc` file by running:
```bash ```bash
source ~/.bashrc source ~/.bashrc
``` ```
### Manual Installation ### Manual Installation
If you prefer a manual installation process, follow these steps: 1. Copy the `brc-script.sh` and `ccecho.sh` files to the `~/.bashrc.d/scripts-needed/` folder:
1. Copy the `brc-script.sh` file to the `~/.bashrc.d/scripts-needed/` folder:
```bash ```bash
cp brc-script.sh ~/.bashrc.d/scripts-needed/ cp brc-script.sh ccecho.sh ~/.bashrc.d/scripts-needed/
chmod 750 ~/.bashrc.d/scripts-needed/brc-script.sh chmod 750 ~/.bashrc.d/scripts-needed/brc-script.sh ~/.bashrc.d/scripts-needed/ccecho.sh
``` ```
2. Append the following lines to your `.bashrc` file: 2. Append the following lines to your `.bashrc` file:
@@ -82,7 +81,7 @@ If you prefer a manual installation process, follow these steps:
mkdir -p ~/.bashrc.d/scripts-needed ~/.bashrc.d/scripts-enabled ~/.bashrc.d/scripts-available ~/.bashrc.d/scripts-removed mkdir -p ~/.bashrc.d/scripts-needed ~/.bashrc.d/scripts-enabled ~/.bashrc.d/scripts-available ~/.bashrc.d/scripts-removed
``` ```
4. Restart your shell or source `.bashrc`: 4. Reload `.bashrc`:
```bash ```bash
source ~/.bashrc source ~/.bashrc
``` ```
@@ -94,9 +93,9 @@ The `brc-script.sh` script provides a series of commands to manage your .bashrc
- `-c` : Create a new script in the `scripts-available/` folder. - `-c` : Create a new script in the `scripts-available/` folder.
- `-m` : Modify an existing script. - `-m` : Modify an existing script.
- `-l` : List all available and enabled scripts. - `-l` : List all available and enabled scripts.
- `-e <index>` : Enable a script from the `scripts-available/` folder. - `-e` : Enable a script from the `scripts-available/` folder.
- `-d <index>` : Disable an enabled script. - `-d` : Disable an enabled script.
- `-r <index>` : Remove a script, backing it up in `scripts-removed/`. - `-r` : Remove a script, backing it up in `scripts-removed/`.
### Example Commands ### Example Commands
@@ -112,19 +111,50 @@ The `brc-script.sh` script provides a series of commands to manage your .bashrc
- Enable a script: - Enable a script:
```bash ```bash
brc-script -e <index> brc-script -e
``` ```
- Disable a script: - Disable a script:
```bash ```bash
brc-script -d <index> brc-script -d
``` ```
- Remove a script: - Remove a script:
```bash ```bash
brc-script -r <index> brc-script -r
``` ```
## Extra Utilities
### `ccecho`: Colorful Echo for Enhanced Output
The project includes a utility script `ccecho.sh` located in `scripts-needed/`, which defines a function `ccecho`. This command allows you to print styled and colored messages to the terminal.
#### Usage
```bash
ccecho -t green -b black -s bold "Success!"
ccecho -t red -s underline "Error!"
ccecho "Normal message without styling"
```
#### Available Text Colors
`black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`, `bblack`, `bred`, `bgreen`, `byellow`, `bblue`, `bmagenta`, `bcyan`, `bwhite`
#### Background Colors
Same as above, applied with `-b`
#### Styles
`bold`, `dim`, `italic`, `underline`, `blink`, `reverse`, `hidden`, `strike`
#### Make `ccecho` Globally Available
If you'd like to use `ccecho` in other terminal sessions or scripts, you can source it in your `.bashrc`:
```bash
source ~/.bashrc.d/scripts-needed/ccecho.sh
```
## Why Use This System? ## Why Use This System?
Managing a large .bashrc file can become unmanageable, especially when adding multiple custom commands or functions. This system offers a structured approach to handle modular scripts, making it easier to enable or disable specific configurations without manually editing the .bashrc file each time. Managing a large .bashrc file can become unmanageable, especially when adding multiple custom commands or functions. This system offers a structured approach to handle modular scripts, making it easier to enable or disable specific configurations without manually editing the .bashrc file each time.

View File

@@ -1,7 +1,3 @@
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# Modular Bashrc # Modular Bashrc
mkdir -p ~/.bashrc.d/scripts-needed mkdir -p ~/.bashrc.d/scripts-needed
mkdir -p ~/.bashrc.d/scripts-enabled mkdir -p ~/.bashrc.d/scripts-enabled

View File

@@ -21,57 +21,57 @@ bashrc="${home_folder}.bashrc"
# Refresh Bash # # Refresh Bash #
refresh-brc(){ refresh-brc(){
if [ "$1" == "-dis" ]; then if [ "$1" == "-dis" ]; then
echo "------------------------------------" echo "------------------------------------"
echo "[ Bashrc Refreshed ]" ccecho -t bblue "[ Bashrc Refreshed ]"
echo "You can't use the old commands from now!" echo "You can't use the old commands from now!"
echo "------------------------------------" echo "------------------------------------"
elif [ "$1" == "-en" ]; then elif [ "$1" == "-en" ]; then
echo "------------------------------------" echo "------------------------------------"
echo "[ Bashrc Refreshed ]" ccecho -t bblue "[ Bashrc Refreshed ]"
echo "------------------------------------" echo "------------------------------------"
echo "You can you the new commands from now!" ccecho -t bgreen -s bold "You can you the new commands from now!"
echo "------------------------------------" echo "------------------------------------"
else else
echo "[ Bashrc Refreshed ]" ccecho -t bblue "[ Bashrc Refreshed ]"
fi fi
source "$bashrc" source "$bashrc"
} }
createscript() { createscript() {
echo "------------------------------------" echo "------------------------------------"
echo " Creation New Scripts: " echo " Creation New Scripts: "
echo "------------------------------------" echo "------------------------------------"
echo "Name of the script: " echo "Name of the script: "
read namenewscript read namenewscript
if [ -f "${available_scripts}$namenewscript" ]; then if [ -f "${available_scripts}$namenewscript" ]; then
echo "Script already exists!" ccecho -t byellow "Script already exists!"
else else
newscriptav="${available_scripts}$namenewscript.sh" newscriptav="${available_scripts}$namenewscript.sh"
### INITIALIZZATION NEW SCRIPT ### ### INITIALIZZATION NEW SCRIPT ###
touch $newscriptav touch $newscriptav
echo "#!/bin/bash" >> $newscriptav echo "#!/bin/bash" >> $newscriptav
echo "" >> $newscriptav echo "" >> $newscriptav
echo "### OPTIONS ###" >> $newscriptav echo "### OPTIONS ###" >> $newscriptav
echo "" >> $newscriptav echo "" >> $newscriptav
echo "" >> $newscriptav echo "" >> $newscriptav
echo "### VARIABLES ###" >> $newscriptav echo "### VARIABLES ###" >> $newscriptav
echo "" >> $newscriptav echo "" >> $newscriptav
echo "" >> $newscriptav echo "" >> $newscriptav
echo "### FUNCTIONS ###" >> $newscriptav echo "### FUNCTIONS ###" >> $newscriptav
echo "${namenewscript}() {" >> $newscriptav echo "${namenewscript}() {" >> $newscriptav
echo "# Add your code here!" >> $newscriptav echo "# Add your code here!" >> $newscriptav
echo 'echo "This is the new script"' >> $newscriptav echo 'echo "This is the new script"' >> $newscriptav
echo "}" >> $newscriptav echo "}" >> $newscriptav
echo "" >> $newscriptav echo "" >> $newscriptav
echo "### EXECUTE ###" >> $newscriptav echo "### EXECUTE ###" >> $newscriptav
echo "" >> $newscriptav echo "" >> $newscriptav
echo "" >> $newscriptav echo "" >> $newscriptav
### END NEW SCRIPT ### ### END NEW SCRIPT ###
vim "$newscriptav" vim "$newscriptav"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "------------------------------------" echo "------------------------------------"
echo " Editor aborted!" echo " Editor aborted!"
@@ -87,67 +87,72 @@ createscript() {
return return
fi fi
fi fi
echo "------------------------------------" echo "------------------------------------"
echo " Script $namenewscript created!" echo " Script $namenewscript created!"
echo " Do you want to enable it?" echo " Do you want to enable it?"
echo "------------------------------------" echo "------------------------------------"
echo " 1 | yes " echo " 1 | yes "
echo " 2 | no " echo " 2 | no "
echo " Def | no " echo " Def | no "
echo "------------------------------------" echo "------------------------------------"
read answer read answer
if [ "$answer" -eq 1 ]; then if [ "$answer" -eq 1 ]; then
ln -sf "$newscriptav" "${enabled_scripts}$namenewscript.sh" ln -sf "$newscriptav" "${enabled_scripts}$namenewscript.sh"
refresh-brc -en refresh-brc -en
else else
echo "Script not enabled!" ccecho -t byellow "Script not enabled!"
fi fi
fi fi
} }
listitem() { listitem() {
index=0 index=0
for i in $(ls "$available_scripts"); do for i in $(ls "$available_scripts"); do
inotext=${i:0:-3} inotext=${i:0:-3}
(( index ++ )) (( index ++ ))
enabled="" enabled=""
if [ -f "$enabled_scripts$i" ]; then if [ -f "$enabled_scripts$i" ]; then
enabled="-" enabled='-'
fi fi
printf "%5d | %1s %s\n" "$index" "$enabled" "$inotext" if [ "$enabled" == "-" ]; then
printf "%5d | %1s %s\n" "$index" "$( ccecho -t blue -s bold $enabled)" "$( ccecho -t green $inotext)"
else
printf "%5d | %1s %s\n" "$index" "$enabled" "$( ccecho -t yellow $inotext)"
fi
done done
} }
managescript() { managescript() {
echo "------------------------------------" echo "------------------------------------"
echo " Select the index: " echo " Select the index: "
echo "------------------------------------" echo "------------------------------------"
read manageindex read manageindex
index2=1 index2=1
for i in $(ls "$available_scripts"); do for i in $(ls "$available_scripts"); do
if [ "$manageindex" == "$index2" ]; then if [ "$manageindex" == "$index2" ]; then
# DISABLE WITH NUMBER # # DISABLE WITH NUMBER #
if [ "$1" == "--disable" ]; then if [ "$1" == "--disable" ]; then
if [ ! -f "${enabled_scripts}$i" ]; then if [ ! -f "${enabled_scripts}$i" ]; then
echo "Script not enabled!" ccecho -t byellow "Script not enabled!"
else else
unlink "${enabled_scripts}$i" unlink "${enabled_scripts}$i"
inoext=${i:0:-3} inoext=${i:0:-3}
echo "[ Scripts $inoext Disabled ]" ccecho -t bmagenta -s bold "[ Scripts $inoext Disabled ]"
refresh-brc -dis refresh-brc -dis
fi fi
# ENABLE WITH NUMBER # # ENABLE WITH NUMBER #
elif [ "$1" == "--enable" ]; then elif [ "$1" == "--enable" ]; then
if [ -f "${enabled_scripts}$i" ]; then if [ -f "${enabled_scripts}$i" ]; then
echo "Script already enabled!" ccecho -t bblue "Script already enabled!"
else else
ln -sf "$available_scripts$i" "${enabled_scripts}$i" ln -sf "$available_scripts$i" "${enabled_scripts}$i"
inoext=${i:0:-3} inoext=${i:0:-3}
echo "------------------------------------" echo "------------------------------------"
echo "[ Scripts $inoext Enabled ]" ccecho -t bgreen -s bold "[ Scripts $inoext Enabled ]"
refresh-brc -en refresh-brc -en
fi fi
# MODIFY WITH NUMBER # # MODIFY WITH NUMBER #
elif [ "$1" == "--modify" ]; then elif [ "$1" == "--modify" ]; then
@@ -168,69 +173,69 @@ managescript() {
vim "$available_scripts$i" vim "$available_scripts$i"
fi fi
fi fi
clear clear
echo "------------------------------------" echo "------------------------------------"
echo "Would you like to rename the script?" echo "Would you like to rename the script?"
echo "------------------------------------" echo "------------------------------------"
echo " 1 | yes " echo " 1 | yes "
echo " 2 | no " echo " 2 | no "
echo " default | no " echo " default | no "
echo "------------------------------------" echo "------------------------------------"
read renscr read renscr
if [ $renscr == "1" ]; then if [ $renscr == "1" ]; then
clear clear
countloop=0 countloop=0
while [ $countloop -lt 1 ]; do while [ $countloop -lt 1 ]; do
echo "------------------------------------" echo "------------------------------------"
echo "Insert new name:" echo "Insert new name:"
read renamenow read renamenow
echo "------------------------------------" echo "------------------------------------"
echo "Is the name correct? " echo "Is the name correct? "
echo "------------------------------------" echo "------------------------------------"
echo " 1 | no " echo " 1 | no "
echo " 0 | yes " echo " 0 | yes "
echo " default | yes " echo " default | yes "
echo "------------------------------------" echo "------------------------------------"
read confirm read confirm
if [ "$confirm" == "1" ]; then if [ "$confirm" == "1" ]; then
countloop=0 countloop=0
clear clear
echo "------------------------------------" echo "------------------------------------"
echo "Rename again the file:" echo "Rename again the file:"
else else
wasenabled=0 wasenabled=0
if [ -f "$enabled_scripts$i" ]; then if [ -f "$enabled_scripts$i" ]; then
unlink "$enabled_scripts$i" unlink "$enabled_scripts$i"
echo "[ Temporary Disabled Script ]" ccecho -t byellow "[ Temporary Disabled Script ]"
wasenabled=1 wasenabled=1
fi fi
mv "$available_scripts$i" "${available_scripts}$renamenow.sh" mv "$available_scripts$i" "${available_scripts}$renamenow.sh"
echo "[ Script $i renamed to $renamenow.sh ]" ccecho -t blue "[ Script $i renamed to $renamenow.sh ]"
if [ "$wasenabled" -eq 1 ]; then if [ "$wasenabled" -eq 1 ]; then
ln -sf "${available_scripts}$renamenow.sh" "${enabled_scripts}$renamenow.sh" ln -sf "${available_scripts}$renamenow.sh" "${enabled_scripts}$renamenow.sh"
echo "[ Script Enabled Again ]" ccecho -t bgreen "[ Script Enabled Again ]"
fi fi
countloop=1 countloop=1
fi fi
done done
fi fi
refresh-brc -en refresh-brc -en
# REMOVE SCRIPT # # REMOVE SCRIPT #
elif [ "$1" == "--remove" ]; then elif [ "$1" == "--remove" ]; then
if [ ! -d "$bin_folder" ]; then if [ ! -d "$bin_folder" ]; then
mkdir $bin_folder mkdir $bin_folder
fi fi
if [ -f "${enabled_scripts}$i" ]; then if [ -f "${enabled_scripts}$i" ]; then
unlink "${enabled_scripts}$i" unlink "${enabled_scripts}$i"
echo "[ Script $i unabled! ]" ccecho -t yellow "[ Script $i unabled! ]"
fi fi
removed_data="$i-`date +%F`_`date +%T`" removed_data="$i-`date +%F`_`date +%T`"
mv "${available_scripts}$i" "${bin_folder}$removed_data" mv "${available_scripts}$i" "${bin_folder}$removed_data"
echo "[ Script $i removed! ] " ccecho -t bmagenta "[ Script $i removed! ] "
echo "You can find it in the folder: " echo "You can find it in the folder: "
echo "'$bin_folder' " echo "'$bin_folder' "
echo "------------------------------------" echo "------------------------------------"
refresh-brc refresh-brc
fi fi
break break
@@ -240,52 +245,58 @@ managescript() {
} }
removescript(){ removescript(){
echo "------------------------------------" echo "------------------------------------"
echo " Remove Script " echo " Remove Script "
echo "------------------------------------" echo "------------------------------------"
listitem listitem
managescript --remove managescript --remove
} }
enablescript() { enablescript() {
echo "------------------------------------" echo "------------------------------------"
echo " Enable Scripts " echo " Enable Scripts "
echo "------------------------------------" echo "------------------------------------"
listitem listitem
managescript --enable managescript --enable
} }
enableallscript() { enableallscript() {
for i in $(ls "$available_scripts"); do echo "------------------------------------"
ln -sf "$available_scripts$i" "${enabled_scripts}$i" echo " Enable All Scripts "
echo "------------------------------------"
for i in $(ls "$available_scripts"); do
ln -sf "$available_scripts$i" "${enabled_scripts}$i"
inoext=${i:0:-3} inoext=${i:0:-3}
echo "enabled $inoext" echo -n "enabled " && ccecho -t green -s underline "$inoext"
done done
echo "------------------------------------" echo "------------------------------------"
echo "[ All available scripts enabled ]" ccecho -t bgreen -s bold "[ All available scripts enabled ]"
refresh-brc -en refresh-brc -en
} }
disablescript() { disablescript() {
echo "------------------------------------" echo "------------------------------------"
echo " Disable Scripts " echo " Disable Scripts "
echo "------------------------------------" echo "------------------------------------"
listitem listitem
managescript --disable managescript --disable
} }
disableallscript() { disableallscript() {
# Disabilita tutti gli script echo "------------------------------------"
for i in $(ls "$enabled_scripts"); do echo " Disable All Enabled Scripts "
unlink "${enabled_scripts}$i" echo "------------------------------------"
inoext=${i:0:-3} # Disabilita tutti gli script
echo "disabled $inoext" for i in $(ls "$enabled_scripts"); do
done unlink "${enabled_scripts}$i"
echo "------------------------------------" inoext=${i:0:-3}
echo "[ All Scripts Disabled ]" echo -n "disabled " && ccecho -t red -s underline "$inoext"
refresh-brc -dis done
echo "------------------------------------"
ccecho -t bmagenta -s bold "[ All Scripts Disabled ]"
refresh-brc -dis
} }
################# #################
@@ -294,60 +305,61 @@ disableallscript() {
# Main Script # # Main Script #
brc-script() { brc-script() {
### ENABLE SCRIPTS ### ### ENABLE SCRIPTS ###
if [ "$1" == "-e" ]; then if [ "$1" == "-e" ]; then
enablescript enablescript
### ENABLE ALL SCRIPTS ### ### ENABLE ALL SCRIPTS ###
elif [ "$1" == "-ea" ]; then elif [ "$1" == "-ea" ]; then
enableallscript enableallscript
### DISABLE SCRIPT ### ### DISABLE SCRIPT ###
elif [ "$1" == "-d" ]; then elif [ "$1" == "-d" ]; then
disablescript disablescript
### DISABLE ALL SCRIPTS ### ### DISABLE ALL SCRIPTS ###
elif [ "$1" == "-da" ]; then elif [ "$1" == "-da" ]; then
disableallscript disableallscript
### SCRIPTS LIST ### ### SCRIPTS LIST ###
elif [ "$1" == "-l" ]; then elif [ "$1" == "-l" ]; then
echo "------------------------------------" echo "------------------------------------"
echo " Scripts List " echo " Scripts List "
echo "------------------------------------" echo "------------------------------------"
listitem listitem
echo "------------------------------------" echo "------------------------------------"
echo " The script preceded by the" echo " The script preceded by the"
echo " '-' character is active. " echo " '-' character is active. "
echo "------------------------------------" echo "------------------------------------"
### MODIFY SCRIPTS ### ### MODIFY SCRIPTS ###
elif [ "$1" == "-m" ]; then elif [ "$1" == "-m" ]; then
echo "###### MODIFY SCRIPTS #######" echo "###### MODIFY SCRIPTS #######"
listitem listitem
managescript --modify managescript --modify
### CREATE NEW SCRIPT ### ### CREATE NEW SCRIPT ###
elif [ "$1" == "-c" ]; then elif [ "$1" == "-c" ]; then
createscript createscript
### REMOVE SCRIPT ### ### REMOVE SCRIPT ###
elif [ "$1" == "-r" ]; then elif [ "$1" == "-r" ]; then
removescript removescript
### COMMAND LISTS ### ### COMMAND LISTS ###
else else
echo "-----------------------------" echo "-----------------------------"
echo " List of brc-scripts command " echo " List of brc-scripts command "
echo "-----------------------------" echo "-----------------------------"
echo " -c | Create New Script " echo " -c | Create New Script "
echo " -m | Modify Script " echo " -m | Modify Script "
echo " -l | Scripts List " echo " -l | Scripts List "
echo " -e | Enable Scripts " echo " -e | Enable Scripts "
echo " -d | Disable Scripts " echo " -d | Disable Scripts "
echo " -da | Disable All Scripts " echo " -da | Disable All Scripts "
echo " -ea | Enable All Scripts " echo " -ea | Enable All Scripts "
echo " -r | Remove Script " echo " -r | Remove Script "
echo "-----------------------------" echo "-----------------------------"
fi fi
} }

51
scripts-needed/ccecho.sh Normal file
View File

@@ -0,0 +1,51 @@
#!/bin/bash
ccecho() {
local text_color=""
local bg_color=""
local style=""
local msg=""
# Color and Styles in ANSI code
declare -A COLORS=(
[black]=30 [red]=31 [green]=32 [yellow]=33 [blue]=34
[magenta]=35 [cyan]=36 [white]=37
[bblack]=90 [bred]=91 [bgreen]=92 [byellow]=93
[bblue]=94 [bmagenta]=95 [bcyan]=96 [bwhite]=97
)
declare -A BGCOLORS=(
[black]=40 [red]=41 [green]=42 [yellow]=43 [blue]=44
[magenta]=45 [cyan]=46 [white]=47
[bblack]=100 [bred]=101 [bgreen]=102 [byellow]=103
[bblue]=104 [bmagenta]=105 [bcyan]=106 [bwhite]=107
)
declare -A STYLES=(
[bold]=1 [dim]=2 [italic]=3 [underline]=4
[blink]=5 [reverse]=7 [hidden]=8 [strike]=9
)
# Parsing options
while [[ $# -gt 0 ]]; do
case "$1" in
-t|--text) text_color=${COLORS[$2]}; shift 2 ;;
-b|--bg) bg_color=${BGCOLORS[$2]}; shift 2 ;;
-s|--style) style=${STYLES[$2]}; shift 2 ;;
*) msg+="$1 "; shift ;;
esac
done
local sequence=""
[[ -n "$style" ]] && sequence+="${style};"
[[ -n "$text_color" ]] && sequence+="${text_color};"
[[ -n "$bg_color" ]] && sequence+="${bg_color};"
if [[ -n "$sequence" ]]; then
sequence="${sequence%;}" # remove the last ";"
echo -e "\e[${sequence}m${msg}\e[0m"
else
echo "$msg"
fi
}