r_bash – Telegram
Appfetch - a database of official installation sources of apps

One thing I like about linux is that in theory, all you have to do is apt install app instead of having to search for it online. Unfortunately due to fragmentation you have to use tools that query all package managers, and you can't be sure of the authenticity.

Appfetch tries to solve it by having a database of official snaps and flatpaks and custom entries that install the app you want from its official source. If it can't find the app, it launches mpm search which is one of the tools for querying all package managers.


Example of an entry that's not an official flatpak/snap:

yt-dlp:
custom: mkdir -p ~/Applications && cd ~/Applications && wget LINK/yt-dlp && chmod +x yt-dlp
uninstall: rm -rf $HOME/Applications/yt-dlp
aliases: [ytdlp, yt]
comment: Youtube video downloading tool



https://redd.it/1kxnsp4
@r_bash
Pomodoro CLI Timer 🍅

I came across bashbunni's cli pomodoro timer and added a few tweaks to allow custom durations and alerts in `.wav` format.

Kind of new to the command line an bash noscripting in general. This was fun to do and to learn more about bash.

If anyone has time to give feedback I'd appreciate it.

You can find the repo here.

https://redd.it/1ky7v8i
@r_bash
Bash LVM Script: lvs | grep Fails to Detect Existing Snapshots for Numbering and Purge

Hello,

I have a Bash noscript (run with `sudo`) for managing LVM snapshots. It's designed to create numbered snapshots (e.g., `lv_lv_projectdata_hourly_1`, then `lv_lv_projectdata_hourly_2`, etc.) and purge old ones based on a retention policy.

My global variables are: `VG_NAME="vg_projectdata"` `LV_NAME="lv_projectdata"` (the name of the original logical volume)

**Persistent Issues:**

1. **Snapshot Creation:**
* The noscript consistently tries to create the snapshot `lv_lv_projectdata_hourly_1`.
* This fails with an "snapshot ... already exists" error.
* The command used to find the last existing snapshot number is: `lvs --noheadings -o lv_name "$VG_NAME" 2>/dev/null | grep -oP "^lv_${LV_NAME}_hourly_\K(\d+)" | sort -nr | head -n 1` This command doesn't seem to detect the existing `_1` snapshot, so the "next number" is always calculated as `1`.
2. **Snapshot Purging:**
* My purge function uses this command to list snapshots: `lvs --noheadings -o lv_name "$VG_NAME" | grep "^lv_${LV_NAME}_hourly_"`
* It consistently reports finding "0 snapshots", even though `lv_lv_projectdata_hourly_1` definitely exists (as confirmed by the error in the creation function).

I can't figure out why the `lvs | grep` pipelines in both functions are failing to identify/match the existing `lv_lv_projectdata_hourly_1` snapshot, which is present in the LVM VG.

Does anyone have debugging tips or ideas on what might be causing this detection failure?

Thanks in advance for your help!

https://redd.it/1kxeue3
@r_bash
Minimal MCP server SDK in Bash with dynamic tool dispatch

This is a pure Bash SDK for building your own MCP stdio server.
It handles the MCP protocol (initialize, tools/list, tools/call) and dispatches to functions named tool_*.

Just write your tools as functions, and the core takes care of the rest. Uses jq for JSON parsing.

Repo: https://github.com/muthuishere/mcp-server-bash-sdk

Blog: https://muthuishere.medium.com/why-i-built-an-mcp-server-sdk-in-shell-yes-bash-6f2192072279


https://redd.it/1kyvj47
@r_bash
Which subjects or articles interest you the most?

Hey all,
Recently, I posted an article that caused some controversy. I believe every person is represents a constant change.

Therefore, I would like to ask you, what are the top 10 things that comes to mind - that I could implement in my next topics & articles? What subjects interest this community the most (in regards to Bash)?

Heinan

https://redd.it/1kz9owa
@r_bash
bash equivelent of Golang's Defer

just for fun!

function foo() {
local defer=()
trap 'local i; for i in ${!defer@}; do eval "${defer-($i+1)}"; done' RETURN

touch tmpa.txt
defer+=('rm tmp
a.txt; echo tmpa.txt deleted')

touch tmp
b.txt
defer+=('rm tmpb.txt; echo tmpb.txt deleted')

touch tmpc.txt
defer+=('rm tmp
c.txt; echo tmpc.txt deleted')

echo "doing some things"
}

output:

doing some things
tmp
c.txt deleted
tmpb.txt deleted
tmp
a.txt deleted

https://redd.it/1kzadem
@r_bash
noscript for automatically converting images in markdown file to base64?

Hi everybody,

I have done this manually before, but before I activate my beginner spaghetti code skills, I figured I'd ask here if something like this already exists...

As you can see here, it is possible to hardcode images in markdown files by converting said images to base64, then linking them (![Hello World](data:image/png;base64,<base64>).

While this enlarges the markdown file (obviously), it allows to have a single file containing everything there is to, for example, a tutorial.

Is anybody aware of a noscript that iterates through a markdown file, finds all images (locally stored and/or hosted on the internet) and replaces these markdown links to base64 encoded versions?

Use case: when following written tutorials from github repos, I often find myself cloning those repos (or at least saving the README.md file). Usually, the files are linked, so the images are hosted on, for example, github, and when viewing the file locally, the images get loaded. But I don't want to rely on that, in case some repo gets deleted or perhaps the internet is down just when it's important to see that one image inside that one important markdown file.

So yeah. If you are aware of a noscript that does this, can you please point me to it? Thanks in advance for your help :)

https://redd.it/1kzuuu3
@r_bash
-- Need help to practise and learn bash, So i am trying to learn bash as i am trying to get into DevOps role, i have explored basic syntax and other core concepts. How do i practise and get good at bash. Do u have any suggestion or any playground beginner friendly!



https://redd.it/1kzl9yi
@r_bash
Lazyshell - AI cli tool that generate shell commands from natural language
https://redd.it/1l02cry
@r_bash
Question regarding learning resources

I know the old adage of just use the tool in order to learn It properly and how useful man pages in general can be. However i was wondering (i have been unable to find any such resources and hence the reason im asking here)
If there exists any tool analogous to vim adventures.
Games/gamified resources where the mechanics to accomplish the thing you want to accomplish are bash. It might sound stupid but It just engages the brain in a different way than just parsing text for tools you might not have an use for yet or dont fully understand at the moment.
I do understand this is an extremely noobish question, patience is appreciated.
Thank you all.

https://redd.it/1l04n3y
@r_bash
Do you 'vibe code' your Bash noscripts?

AI tools seem to handle Bash better than Terraform. Do you plan yours or wing it?

https://redd.it/1l1hbq1
@r_bash
How would I make a noscript that can install packages on either ubuntu or fedora?

I want to build a noscript that can install packages like python3 (as an example; I know lots of distros come with python) that will work with ubuntu or fedora. Since ubuntu uses apt and fedora uses dnf, I thought I could simply use something like

if $(apt --version) ; then
sudo apt install python3
else
sudo dnf install python3

Then I ran into trouble trying to find a resource that will tell me how to get the apt version. How can I get a truthy value to result in using apt install... and a falsy value to result in the else dnf install...?

https://redd.it/1l1r0sj
@r_bash
🛠️ Bash Script: Recursively Convert FLAC to MP3, Organize by Metadata, and Auto-Install Dependencies

Hey all,

I made a simple but powerful Bash noscript to recursively convert `.flac` files into `.mp3`, auto-organize the output using embedded metadata, and optionally delete the original files or play a completion sound.

# 🔧 Features

* Converts `.flac` → `.mp3` using `ffmpeg`
* Extracts `ARTIST`, `ALBUM`, and `TITLE` from FLAC metadata
* Outputs files to: `./output/Artist/Album/track_noscript.mp3`
* Sanitizes filenames (no spaces or special chars)
* Optionally deletes original `.flac` files
* Optionally plays a completion `.mp3` via `mpg123`
* Auto-installs missing dependencies (where possible)

# 📦 Dependencies

Install manually, or let the noscript handle it:

bashCopyEdit# Debian / Ubuntu
sudo apt install -y ffmpeg flac mpg123

# Fedora
sudo dnf install -y ffmpeg flac mpg123

# Arch
sudo pacman -Sy --noconfirm ffmpeg flac mpg123

# macOS
brew install ffmpeg flac mpg123


# 📝 Example Usage

bashCopyEdit./flac_to_mp3.sh /path/to/flac --delete --play


# 📂 Output Structure

textCopyEdit./output/
└── Artist/
└── Album/
└── track_noscript.mp3


# 💾 Source + README

📁 [https://github.com/Blake-and-Watt/linux\_flac\_to\_mp3](https://github.com/Blake-and-Watt/linux_flac_to_mp3)
[https://ko-fi.com/makingagifree](https://ko-fi.com/makingagifree)

https://redd.it/1l1kzie
@r_bash
emoji picker noscript (macos)

Hi everyone, I made this noscript to work as an emoji picker. For some reason, the output is characters like this: üòÄ instead of the actual emoji. How can I fix this?

#!/usr/bin/env bash

selection=$(
# cut -d ';' -f1 "$HOME/.config/noscripts/stuff/emoji" | \
cat "$HOME/.config/noscripts/stuff/emoji" | \
choose -f "JetBrainsMono Nerd Font" -b "31748f" -c "eb6f92" | \
sed "s/ .//"
)

[[ -z "$selection" ]] && exit 1

printf "%s" "$selection" | pbcopy

osanoscript -e 'tell application "System Events" to keystroke "v" using {command down}'Hi everyone, I made this noscript to work as an emoji picker. For some reason, the output is characters like this: üòÄ instead of the actual emoji. How can I fix this? I will attach an image of the choose screen below.#!/usr/bin/env bash

selection=$(
# cut -d ';' -f1 "
$HOME/.config/noscripts/stuff/emoji" | \
cat "
$HOME/.config/noscripts/stuff/emoji" | \
choose -f "JetBrainsMono Nerd Font" -b "31748f" -c "eb6f92" | \
sed "s/ .
//"
)

[ -z "$selection" ] && exit 1

printf "%s" "$selection" | pbcopy

osanoscript -e 'tell application "System Events" to keystroke "v" using {command down}'

https://redd.it/1l2oxdm
@r_bash
What's your Bash noscript logging setup like?

Do you pipe everything to a file? Use tee? Write your own log function with timestamps?
Would love to see how others handle logging for noscripts that run in the background or via cron.

https://redd.it/1l38wbq
@r_bash
How to get an arbitrary integer to align with closest value in array

I have an array that looks like this array=(4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100) and i want to calculate to which value from said array $1 will be closer to, so let's say $1 is 5, i want it to be perceived as 4, and if $1 is 87, i want it to be perceived as 88, and so on.
I tried doing it in awk and it worked, but i really want to get pure bash solution

https://redd.it/1l38vuw
@r_bash
How to delete multiple lines only AFTER a search pattern?

I have a file in the standard INI config file structure, so basically

; last modified 1 April 2001 by John Doe
owner
name = John Doe
organization = Acme Widgets Inc.

database
; use IP address in case network name resolution is not working
server = 192.0.2.62
port = 143
file = "payroll.dat"

I want to get rid of all key-value pairs in one specific block, but keep the section header. Number of key-value pairs may be variable, so a fixed line solution wouldn't suffice.

In the example above, the desired replace operation would result in

; last modified 1 April 2001 by John Doe
owner
name = John Doe
organization = Acme Widgets Inc.

database

Any idea how to accomplish this? I tried with sed, but I couldn't get it to work.

https://redd.it/1l3v0b7
@r_bash
BioBASH v0.3.12

https://preview.redd.it/vqfnz6mb955f1.png?width=1320&format=png&auto=webp&s=d4fa3b0e2260c507395add813ff53b70a45ed246

Hey guys this is a "side" project I started as part of my sabbatical leave. Basically is a Suite of tools for bioinformatics written in BASH.

https://github.com/ampinzonv/BB3/wiki

I am sure it has more bugs that i've been able to find, so this is the first time I publish any version, if you find it somehow interesting and are willing to contribute.

Best,

https://redd.it/1l45be3
@r_bash