-p view source code of the script with lines number, -v shows only the plain script
This commit is contained in:
+10
-7
@@ -59,7 +59,7 @@ Invece di accumulare centinaia di alias, funzioni, variabili d'ambiente e prompt
|
|||||||
| ❌ Difficile isolare bug e testare modifiche | ✅ Attiva o disattiva i moduli all'istante (`brc-script -e` / `-d`) |
|
| ❌ Difficile isolare bug e testare modifiche | ✅ Attiva o disattiva i moduli all'istante (`brc-script -e` / `-d`) |
|
||||||
| ❌ Rischio di rompere l'intera shell per un errore | ✅ Attivazione sicura tramite symlink e backup automatici |
|
| ❌ Rischio di rompere l'intera shell per un errore | ✅ Attivazione sicura tramite symlink e backup automatici |
|
||||||
| ❌ Complesso condividere o sincronizzare snippet | ✅ File modulari pronti per essere condivisi o versionati |
|
| ❌ Complesso condividere o sincronizzare snippet | ✅ File modulari pronti per essere condivisi o versionati |
|
||||||
| ❌ Necessità di aprire editor di testo per leggere i file | ✅ Anteprima immediata da terminale con numeri di riga (`brc-script -p`) |
|
| ❌ Necessità di aprire editor di testo per leggere i file | ✅ Anteprima immediata o cat da terminale (`brc-script -p` / `-v`) |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -74,8 +74,8 @@ Invece di accumulare centinaia di alias, funzioni, variabili d'ambiente e prompt
|
|||||||
- ⚡ **Gestione Massiva Multi-Script**
|
- ⚡ **Gestione Massiva Multi-Script**
|
||||||
Abilita, disabilita, visualizza o rimuovi più script simultaneamente passando gli ID numerici o i nomi dei file (es. `brc-script -e 1 3 4` oppure `brc-script -d 03_bashboard 04_aliases`).
|
Abilita, disabilita, visualizza o rimuovi più script simultaneamente passando gli ID numerici o i nomi dei file (es. `brc-script -e 1 3 4` oppure `brc-script -d 03_bashboard 04_aliases`).
|
||||||
|
|
||||||
- 👁️ **Anteprima Rapida del Codice (`cat`)**
|
- 👁️ **Anteprima e Cat Immediato del Codice (`-p` / `-v`)**
|
||||||
Ispeziona il contenuto e la sintassi di uno script direttamente nel terminale con intestazioni colorate e numerazione delle righe senza dover aprire editor esterni (`brc-script -p <id|nome>`).
|
Ispeziona il codice di uno script direttamente nel terminale senza dover aprire editor esterni. Usa `brc-script -p <id|nome>` per l'anteprima numerata con intestazioni a colori, oppure `brc-script -v <id|nome>` (o `--cat`) per visualizzare il codice pulito senza numeri di riga.
|
||||||
|
|
||||||
- 🖥️ **Bashboard di Sistema Intelligente**
|
- 🖥️ **Bashboard di Sistema Intelligente**
|
||||||
Include `03_bashboard.sh`, una dashboard stile MOTD veloce che mostra CPU, RAM, dischi, temperatura, IP locali/pubblici, aggiornamenti di sistema e il **rilevamento dinamico automatico della Web UI di Cockpit**.
|
Include `03_bashboard.sh`, una dashboard stile MOTD veloce che mostra CPU, RAM, dischi, temperatura, IP locali/pubblici, aggiornamenti di sistema e il **rilevamento dinamico automatico della Web UI di Cockpit**.
|
||||||
@@ -167,7 +167,8 @@ Il comando principale per gestire l'intero ambiente è `brc-script`.
|
|||||||
| Azione | Flag / Alias | Argomenti | Descrizione |
|
| Azione | Flag / Alias | Argomenti | Descrizione |
|
||||||
| :--- | :--- | :--- | :--- |
|
| :--- | :--- | :--- | :--- |
|
||||||
| **Elenco Script** | `-l`, `--list`, `list` | *nessuno* | Mostra tutti gli script, l'ID numerico e lo stato di attivazione (`-` blu) |
|
| **Elenco Script** | `-l`, `--list`, `list` | *nessuno* | Mostra tutti gli script, l'ID numerico e lo stato di attivazione (`-` blu) |
|
||||||
| **Anteprima / Cat** | `-p`, `-v`, `--cat`, `--show`, `cat` | `<id\|nome ...>` | Stampa a terminale il codice con numeri di riga senza aprire editor |
|
| **Anteprima (Numerata)** | `-p`, `--preview`, `preview` | `<id\|nome ...>` | Stampa il codice con numeri di riga e intestazione informativa |
|
||||||
|
| **Cat / Vista (Semplice)** | `-v`, `--cat`, `--view`, `--show`, `cat`, `view` | `<id\|nome ...>` | Stampa il codice pulito dello script senza numeri di riga |
|
||||||
| **Abilita** | `-e`, `--enable`, `enable` | `<id\|nome ...>` | Attiva uno o più script creando il symlink in `scripts-enabled/` |
|
| **Abilita** | `-e`, `--enable`, `enable` | `<id\|nome ...>` | Attiva uno o più script creando il symlink in `scripts-enabled/` |
|
||||||
| **Disabilita** | `-d`, `--disable`, `disable` | `<id\|nome ...>` | Disattiva uno o più script rimuovendo il symlink |
|
| **Disabilita** | `-d`, `--disable`, `disable` | `<id\|nome ...>` | Disattiva uno o più script rimuovendo il symlink |
|
||||||
| **Abilita Tutti** | `-ea`, `--enable-all`, `enable-all` | *nessuno* | Attiva contemporaneamente tutti gli script disponibili |
|
| **Abilita Tutti** | `-ea`, `--enable-all`, `enable-all` | *nessuno* | Attiva contemporaneamente tutti gli script disponibili |
|
||||||
@@ -221,13 +222,15 @@ brc-script -d 2 4 5
|
|||||||
brc-script -d 03_bashboard 04_aliases
|
brc-script -d 03_bashboard 04_aliases
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 4. Visualizzare l'Anteprima del Codice Direttamente nel Terminale
|
#### 4. Visualizzare l'Anteprima o Eseguire il Cat del Codice nel Terminale
|
||||||
Esamina cosa fa uno script prima di attivarlo:
|
Esamina cosa fa uno script prima di attivarlo:
|
||||||
```bash
|
```bash
|
||||||
# Anteprima tramite ID numerico
|
# Anteprima con numeri di riga e intestazione formattata
|
||||||
brc-script -p 4
|
brc-script -p 4
|
||||||
|
brc-script --preview 03_bashboard
|
||||||
|
|
||||||
# Anteprima tramite nome script
|
# Stampa (cat) del codice pulito senza numeri di riga (ideale per copia-incolla)
|
||||||
|
brc-script -v 4
|
||||||
brc-script --cat 03_bashboard
|
brc-script --cat 03_bashboard
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ Instead of stuffing hundreds of aliases, functions, exports, and prompt customiz
|
|||||||
| ❌ Hard to debug errors and test changes | ✅ Enable or disable modules instantly (`brc-script -e` / `-d`) |
|
| ❌ Hard to debug errors and test changes | ✅ Enable or disable modules instantly (`brc-script -e` / `-d`) |
|
||||||
| ❌ Risk of accidentally breaking the whole shell | ✅ Safe symlink-based activation and automatic backups |
|
| ❌ Risk of accidentally breaking the whole shell | ✅ Safe symlink-based activation and automatic backups |
|
||||||
| ❌ Impossible to share individual snippets | ✅ Modular files ready to share, version-control, or reuse |
|
| ❌ Impossible to share individual snippets | ✅ Modular files ready to share, version-control, or reuse |
|
||||||
| ❌ Manually editing files to preview snippets | ✅ Instant terminal preview with line numbering (`brc-script -p`) |
|
| ❌ Manually editing files to preview snippets | ✅ Instant terminal preview or cat (`brc-script -p` / `-v`) |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -74,8 +74,8 @@ Instead of stuffing hundreds of aliases, functions, exports, and prompt customiz
|
|||||||
- ⚡ **Multi-Script Batch Management**
|
- ⚡ **Multi-Script Batch Management**
|
||||||
Enable, disable, preview, or remove multiple scripts at the same time using either their numeric ID or script name (e.g. `brc-script -e 1 3 4` or `brc-script -d 03_bashboard 04_aliases`).
|
Enable, disable, preview, or remove multiple scripts at the same time using either their numeric ID or script name (e.g. `brc-script -e 1 3 4` or `brc-script -d 03_bashboard 04_aliases`).
|
||||||
|
|
||||||
- 👁️ **Instant Script Code Preview (`cat`)**
|
- 👁️ **Instant Script Code Preview & Cat (`-p` / `-v`)**
|
||||||
View script contents with colored status headers and line numbering without opening an external editor (`brc-script -p <id|name>`).
|
Inspect script contents directly in the terminal without opening an external editor. Use `brc-script -p <id|name>` for preview with colored headers and line numbers, or `brc-script -v <id|name>` (or `--cat`) for clean code cat without line numbers.
|
||||||
|
|
||||||
- 🖥️ **Smart System Bashboard**
|
- 🖥️ **Smart System Bashboard**
|
||||||
Includes `03_bashboard.sh`, a fast MOTD-style dashboard showing CPU, RAM, disk usage, uptime, distro details, IP addresses, package update counts, and **automatic dynamic discovery of Cockpit Web UI**.
|
Includes `03_bashboard.sh`, a fast MOTD-style dashboard showing CPU, RAM, disk usage, uptime, distro details, IP addresses, package update counts, and **automatic dynamic discovery of Cockpit Web UI**.
|
||||||
@@ -167,7 +167,8 @@ When your shell starts, `~/.bashrc` executes a minimal loader loop that sources
|
|||||||
| Action | Flags / Aliases | Arguments | Description |
|
| Action | Flags / Aliases | Arguments | Description |
|
||||||
| :--- | :--- | :--- | :--- |
|
| :--- | :--- | :--- | :--- |
|
||||||
| **List** | `-l`, `--list`, `list` | *none* | Lists all scripts with IDs, names, and active status (`-` in blue) |
|
| **List** | `-l`, `--list`, `list` | *none* | Lists all scripts with IDs, names, and active status (`-` in blue) |
|
||||||
| **Preview** | `-p`, `-v`, `--cat`, `--show`, `cat` | `<id\|name ...>` | Prints script code with line numbers without opening an editor |
|
| **Preview (Numbered)** | `-p`, `--preview`, `preview` | `<id\|name ...>` | Prints script code with line numbers and status headers |
|
||||||
|
| **Cat / View (Plain)** | `-v`, `--cat`, `--view`, `--show`, `cat`, `view` | `<id\|name ...>` | Prints clean script code without line numbers |
|
||||||
| **Enable** | `-e`, `--enable`, `enable` | `<id\|name ...>` | Activates one or more scripts by creating symlinks in `scripts-enabled/` |
|
| **Enable** | `-e`, `--enable`, `enable` | `<id\|name ...>` | Activates one or more scripts by creating symlinks in `scripts-enabled/` |
|
||||||
| **Disable** | `-d`, `--disable`, `disable` | `<id\|name ...>` | Deactivates one or more scripts by removing symlinks |
|
| **Disable** | `-d`, `--disable`, `disable` | `<id\|name ...>` | Deactivates one or more scripts by removing symlinks |
|
||||||
| **Enable All** | `-ea`, `--enable-all`, `enable-all` | *none* | Enables all available scripts at once |
|
| **Enable All** | `-ea`, `--enable-all`, `enable-all` | *none* | Enables all available scripts at once |
|
||||||
@@ -221,13 +222,15 @@ brc-script -d 2 4 5
|
|||||||
brc-script -d 03_bashboard 04_aliases
|
brc-script -d 03_bashboard 04_aliases
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 4. Previewing Script Code Directly in Terminal
|
#### 4. Previewing and Catting Script Code Directly in Terminal
|
||||||
Inspect what a script does before enabling it:
|
Inspect what a script does before enabling it:
|
||||||
```bash
|
```bash
|
||||||
# Preview using numeric ID
|
# Preview with line numbers and header info
|
||||||
brc-script -p 4
|
brc-script -p 4
|
||||||
|
brc-script --preview 03_bashboard
|
||||||
|
|
||||||
# Preview using script name
|
# Cat clean code without line numbers (easy to copy & paste)
|
||||||
|
brc-script -v 4
|
||||||
brc-script --cat 03_bashboard
|
brc-script --cat 03_bashboard
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -291,7 +291,8 @@ echo ""
|
|||||||
echo "Use commands:"
|
echo "Use commands:"
|
||||||
echo " brc-script -> manage scripts"
|
echo " brc-script -> manage scripts"
|
||||||
echo " brc-script -l -> list scripts"
|
echo " brc-script -l -> list scripts"
|
||||||
echo " brc-script --cat -> preview a script"
|
echo " brc-script -p -> preview script (with line numbers)"
|
||||||
|
echo " brc-script -v -> cat script (plain code)"
|
||||||
echo " brc-script -e -> enable script(s)"
|
echo " brc-script -e -> enable script(s)"
|
||||||
echo " brc-script -d -> disable script(s)"
|
echo " brc-script -d -> disable script(s)"
|
||||||
echo " brc-script --update -> check Gitea updates"
|
echo " brc-script --update -> check Gitea updates"
|
||||||
|
|||||||
@@ -216,17 +216,25 @@ EOF
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Preview / Cat a script
|
# Display helper for cat and preview
|
||||||
catscript() {
|
_display_script() {
|
||||||
|
local numbered="$1"
|
||||||
|
shift
|
||||||
local targets=("$@")
|
local targets=("$@")
|
||||||
|
local action_title="View / Cat Script"
|
||||||
|
local prompt_msg="Select script number(s) or name(s) to view: "
|
||||||
|
if [ "$numbered" -eq 1 ]; then
|
||||||
|
action_title="Preview Script (Numbered)"
|
||||||
|
prompt_msg="Select script number(s) or name(s) to preview: "
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ${#targets[@]} -eq 0 ]; then
|
if [ ${#targets[@]} -eq 0 ]; then
|
||||||
echo "------------------------------------"
|
echo "------------------------------------"
|
||||||
echo " Preview / Cat Script "
|
echo " $action_title"
|
||||||
echo "------------------------------------"
|
echo "------------------------------------"
|
||||||
listitem
|
listitem
|
||||||
echo "------------------------------------"
|
echo "------------------------------------"
|
||||||
read -rp "Select script number(s) or name(s) to preview: " input_str
|
read -rp "$prompt_msg" input_str
|
||||||
# shellcheck disable=SC2206
|
# shellcheck disable=SC2206
|
||||||
targets=($input_str)
|
targets=($input_str)
|
||||||
fi
|
fi
|
||||||
@@ -261,10 +269,14 @@ catscript() {
|
|||||||
ccecho -t white " 📊 Lines: ${total_lines}"
|
ccecho -t white " 📊 Lines: ${total_lines}"
|
||||||
echo "================================================================================"
|
echo "================================================================================"
|
||||||
|
|
||||||
if command -v nl >/dev/null 2>&1; then
|
if [ "$numbered" -eq 1 ]; then
|
||||||
nl -ba -w4 -s': ' "$full_path"
|
if command -v nl >/dev/null 2>&1; then
|
||||||
|
nl -ba -w4 -s': ' "$full_path"
|
||||||
|
else
|
||||||
|
cat -n "$full_path"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
cat -n "$full_path"
|
cat "$full_path"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "================================================================================"
|
echo "================================================================================"
|
||||||
@@ -275,6 +287,16 @@ catscript() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Plain Cat of script(s)
|
||||||
|
catscript() {
|
||||||
|
_display_script 0 "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Numbered Preview of script(s)
|
||||||
|
previewscript() {
|
||||||
|
_display_script 1 "$@"
|
||||||
|
}
|
||||||
|
|
||||||
# Enable one or more scripts by ID or Name
|
# Enable one or more scripts by ID or Name
|
||||||
enablescript() {
|
enablescript() {
|
||||||
local targets=("$@")
|
local targets=("$@")
|
||||||
@@ -669,8 +691,13 @@ brc-script() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
case "$cmd" in
|
case "$cmd" in
|
||||||
### PREVIEW / CAT SCRIPT ###
|
### PREVIEW SCRIPT (WITH LINE NUMBERS) ###
|
||||||
-p|-v|--cat|--view|--show|cat|show|view)
|
-p|--preview|preview)
|
||||||
|
previewscript "$@"
|
||||||
|
;;
|
||||||
|
|
||||||
|
### VIEW / CAT SCRIPT (PLAIN CODE) ###
|
||||||
|
-v|--cat|--view|--show|cat|show|view)
|
||||||
catscript "$@"
|
catscript "$@"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@@ -738,7 +765,8 @@ brc-script() {
|
|||||||
echo " List of brc-script commands "
|
echo " List of brc-script commands "
|
||||||
echo "--------------------------------------------------------"
|
echo "--------------------------------------------------------"
|
||||||
echo " -l, --list | List all scripts "
|
echo " -l, --list | List all scripts "
|
||||||
echo " -p, --cat <id|name ...> | Preview / Cat script(s) "
|
echo " -p, --preview <id|name ...> | Preview (with numbers) "
|
||||||
|
echo " -v, --cat <id|name ...> | Cat / view (plain code) "
|
||||||
echo " -e, --enable <id|name ...> | Enable script(s) "
|
echo " -e, --enable <id|name ...> | Enable script(s) "
|
||||||
echo " -d, --disable <id|name ...> | Disable script(s) "
|
echo " -d, --disable <id|name ...> | Disable script(s) "
|
||||||
echo " -ea, --enable-all | Enable all scripts "
|
echo " -ea, --enable-all | Enable all scripts "
|
||||||
@@ -752,6 +780,7 @@ brc-script() {
|
|||||||
echo " Example: brc-script -d 1 5 12 03_bashboard "
|
echo " Example: brc-script -d 1 5 12 03_bashboard "
|
||||||
echo " Example: brc-script -e 2 4 01_git-cli-highlitgh "
|
echo " Example: brc-script -e 2 4 01_git-cli-highlitgh "
|
||||||
echo " Example: brc-script -p 03_bashboard "
|
echo " Example: brc-script -p 03_bashboard "
|
||||||
|
echo " Example: brc-script -v 03_bashboard "
|
||||||
echo "--------------------------------------------------------"
|
echo "--------------------------------------------------------"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
Reference in New Issue
Block a user