Is this possible? Want to use terminal to show Youtube homepage with slightly better ux.
New to Linux. Installed Ubuntu. Keep reloading youtube home page because recommendations suck. Want to to avoid shorts and other unneeded features by using Youtube solely through bash. Want to know if small quality of life changes can be made.
I'm wondering if it's possible to use the terminal to show a small number of videos from my home page, title with no thumbnail is enough, which shows dislike and like count, make it so that pressing not interested or don't recommend channel is a bit faster to click.
Sorry if this is a weird or absurd ask. I'm going cold turkey on AI overview, but want to see if there should be anything I need to know about starting a project like this.
https://redd.it/1x8aw96
@r_bash
Unset doesn't properly work in functions??
So this is super weird. When I run the following in a script (or manually in the terminal), it does exactly what you'd expect.
declare -A myassoc
myassoc[key]="Hello World"
unset myassoc
declare -p myassoc
echo "This should be empty: ${myassoc[@]}"
./dev2: line 9: declare: myassoc: not foundThis should be empty:myassoc is unset and therefore undeclaredfoo () {
declare -A myassoc
myassoc[key]="Hello World"
unset myassoc
declare -p myassoc
echo "This should be empty: ${myassoc[@]}"
}
foo
declare -- myassocThis should be empty:declare -p to test if variables exist regardless of their type and content.test is not a viable alternative, since it doesn't have the same behaviour for local myvar and declare myvar (vars without value return false, even if declared)bar () {
declare -A myassoc
myassoc[key]="Hello World"
declare -gp myassoc
echo "This should be empty: ${myassoc[@]}"
foo () {
unset myassoc
echo "In foo:"
declare -gp myassoc
echo "This should be empty: ${myassoc[@]}"
}
foo
echo "After foo:"
declare -gp myassoc
echo "This should be empty: ${myassoc[@]}"
}
bar
is there a way to improve a github release updater to pick the right asset name?
i made a script that actually works for most times to update brave browser, but for packages that change names its trivial. the idea is to place, update directory with a file with metadata that i can extract. here is the script :
updatePrograms() {
for dir in ~/Programs/*; do
#meta file structure
if [[ -f "$dir"/update/meta ]]; then
local metadata=$(cat "$dir"/update/meta)
local owner=$( echo "$metadata" | grep "Owner" | sed 's|Owner:||' )
local project=$(echo "$metadata" | grep "Project" | sed 's|Project:||')
local output=$(curl -fsS "https://api.github.com/repos/$owner/$project/releases/latest")
[[ -z "$output" ]] && { echo "no response for $project"; continue; }
local checkVersion=$(jq -r '.tag_name' <<< "$output")
echo "updatable Project : $project"
[[ "$checkVersion" = "null" ]] || [[ -z "$checkVersion" ]] && { echo "couldn't fetch version for $project"; continue; }
local currentVersion=$(echo "$metadata" | grep "Version" | sed 's|Version:||')
[[ "$checkVersion" = "$currentVersion" ]] && { echo "$project is up to date : $checkVersion"; continue; }
while true; do
read -p "$project is on $currentVersion, latest is $checkVersion; do you want to request the latest Version? [y/n]: " response
case "$response" in
[Yy])
echo "Updating.."
local name
name=$(echo "$metadata" | grep "AssetName" | sed 's|AssetName:||')
local url=$(jq -r --arg name "$name" '.assets[] | select(.name == $name) | .browser_download_url' <<< "$output")
if [[ -z "$url" ]] || [[ "$url" = "null" ]]; then
echo "couldn't find asset matching $name"
echo "you may need to change asset name version to $checkVersion"
break
fi
if curl -fL -o "$dir/update/$name" "$url" ; then
sed -i "s|Version:.*|Version:$checkVersion|" "$dir"/update/meta
else
echo "Downloading falied"
break
fi
break;;
[Nn])
echo "not Updating"
break;;
*)
echo "choose y or n";;
esac
done
fi
done
}
https://redd.it/1x66ycu
@r_bash
wiki how ?!
i installed termux and went to the wiki to learn it but for some reson all of the wikis [ arch wiki, official wiki, unofficial wiki, even \] stops with a prof u'r not a robot infenit bage and never work and even github won't upload the page not termux repo or any other repo , i know the problem is with me ; so do you know any other place to learn termux/terminal tools no matter if it's a wiki, a site, or even a book.
* i don't have a computer so don't tell me to use a one
https://redd.it/1x3w9zc
@r_bash
MountSync – A utility I built to sync configs, MP3s, and AI skills across my Linux PCs via rclone
Hi everyone,
I wanted to share a tool I built to solve a personal daily headache: MountSync (mosy).
I use multiple Linux machines, and I needed a reliable way to share active files between them: specifically application configurations, a local MP3 music library, and local AI skill/context folders. I wanted to keep files exactly where they belonged on the local filesystem while seamlessly updating them across PCs in the background.
Since it solved a real-world problem for me, I polished it, added testing, and open-sourced it as a portfolio project.
### What problem does it solve?
Managing rclone mount manually, copying files, creating symbolic links, and making sure systemd services start correctly on every new PC is tedious. MountSync automates the whole process:
1. Auto-mounts: Sets up and manages your rclone mount in the background via systemd user services.
2. Auto-linking: When you run mosy add ~/Music, it moves the target directory to your cloud drive (like Google Drive or OneDrive) and replaces the original path with a clean symbolic link.
3. Instantly sync new PCs: On any new PC, you just install it and run mosy init. It automatically maps all symlinks to your existing cloud folders, syncing your configs, music, and dotfiles in seconds.
The codebase is 100% open source on GitHub:
github.com/GabrielTeixeiral0l/MountSync
I’d love to hear your thoughts, feedback on the code structure, or suggestions for new features!
https://redd.it/1va2fat
@r_bash
Would it be good to Learn Bash scripting, or should i go with a "normal" language, like Python, before that?
Getting interested on messing with Linux and CLI stuff, I'm just confused on what exactly to start with. Any recommendations?
https://redd.it/1v9z70a
@r_bash
History not working on a Ubuntu 26.04 VM
Arrowing back through my command history isn't working for some reason. I have HISTORYSIZE set as 0 in .bashrc, as well as these lines at the bottom:
bind '"\\e[A": history-search-backward'
bind '"\\e[B": history-search-forward'
They're even in the systemwide bashrc file.
What is going on?
https://redd.it/1vawz3g
@r_bash
I built a tool that automates setting up WireGuard remote access VPNs along with other network configurations. It also generates QR codes for clients and lets you check the status of all WireGuard tunnels
https://redd.it/1ve6my2
@r_bash
Terminal Based Universal-Downloader - Supports Youtube/Flathub/Github/Torrents/Direct Links
https://github.com/djkido316/Universal-Downloader
https://redd.it/1verwu8
@r_bash
Bash is way too fun
I'm a construction worker and love tech, switched to Linux last year and wanted to learn BASH just out of curiosity not necessity. The only other language I have experience is GML from when I was a teen.
So I've been building a text adventure and BASH is so fun and for strings it's easy! I've kept it pure bash except for using sleep, I think I understand I could have used read instead of sleep but sleep seems pretty ubiquitous on most computers.
It's messy and definitely an elementary project so I've kept trying to implement different design elements like sourcing data and turning that into arrays, using name refs (I'll be honest using name refs confuses the shit out of me), parsing CSVs, state machines, saving (declare -p) , loading, ect.
If any of you new guys wanna practice something you can easily take on without any AI I advise trying to build a text adventure and not just navigation but include inventory and other mechanics.
And if you're an absolute beginner YSAP bash tutorial was king for me, plus man, and tldr
https://redd.it/1vfk2qh
@r_bash
Login with ssh password with bash only
I can use programs like sshpass/expect to give a ssh password to the ssh command if I don't have pubkey auth. Can I do it using just bash?
Some programs let you pipe a password on stdin can I do anything for ssh?
It is to automate first login with password so I can create add the pubkey auth.
https://redd.it/1vhc093
@r_bash
Jobman: a daemonless CLI for long-running jobs with retries, timeouts, dependencies, and durable logs
I've long used `nohup` for background processes that I want to run independently of the terminal. These types of jobs are usually long-running, sometimes launched over an SSH connection, and often have dependencies on other jobs.
I built [**Jobman**](https://github.com/ryancswallace/jobman) to combine the simplicity of `nohup` with features I previously wrote one-off shell scripts for, including:
* retries
* timeouts
* dependencies between jobs
* email or webhook notifications on completion or failure
* separate stdout and stderr logging with a combined observed-order view
Jobman does this with a small per-job supervisor process; there's no shared daemon to run. It uses SQLite for job and run metadata and plain files for log storage. It's intended to be a local, per-user tool, not a system-wide or distributed scheduler.
Jobman is written in Go and has releases available for Linux, macOS, and Windows. Tested under Bash and Zsh.
Would this replace any of your `nohup`, `tmux`, `screen`, or `systemd-run` workflows? If Jobman looks useful to you, let me know what types of jobs you would use it for.
https://redd.it/1vihvgs
@r_bash
My favorite little bat wrapper I just wrote
I wrote a wrapper function for the wonderful bat that searches a file for a function name and prints just that function and definition to stdout. I've been using it a ton looking through legacy java projects and deployment scripts that I was constantly opening other files to search around for a function definition for. I got sick of sifting through all the function calls.
It DOES NOT work on non "{}" defined function blocks, like python functions, but I'm ok with that for now. I didn't want to deal with all that dynamic whitespace nonsense. I also left in my debugging echo comments.
I got a lot of the logic from this blog post which was incredibly helpful at first, and is why I have the brackets array and multiple stack variables, which ended up not being necessary.
Full disclosure, I queried an LLM for exactly 1 expression: "$line" != *"$funcName"*"{" because I kinda suck at glob expansion and was getting too annoyed.
I'm definitely not a developer by any means so I would love any ideas for improvements or tweaks, or if you catch a bug. And if you end up using it let me know too! enjoy :)
EDIT: I posted the slightly old version that was missing a * before "$funcName"*"{"
#!/usr/bin/env bash
# a bat wrapper that takes two arguments:
# $1 = file to view
# $2 = function to search for in file
fbat() {
#Very basic argument number check
if $# -lt 2 ; then
echo "Must pass at least FILE and FUNCNAME to search"
return 1
fi
#Arguments
local funcName="${2}"
local inputFile="${1}"
shift 2 # so we can pass flags to bat if desired
#Unneccesary brackets array
declare -A brackets=( ""]="" [")"="(" "}"="{" )
local CurlyBracketStack=""
#local SquareBracketStack=""
#local ParenthesisStack=""
#Tracking variables
local startLineNum
local endLineNum
local bounded="false"
local started="false"
local curLineNum=0
#Main while loop over lines in the file
while read -r line; do
#Increment the line number no matter what
(( curLineNum += 1 ))
#Skip comment lines, their brackets don't count
if [ ${line:i:1} == "#" ]; then
#echo "not parsing line ${curLineNum} because it's a comment"
continue
fi
#if
# NOT the first part of the line == function name AND
# NOT the last part of the line == open bracket AND
# NOT started
# don't start reading line
if [ "$started" == "false" && "$line" != *"$funcName"*"{" ]; then
#echo "not parsing line ${curLineNum} because we haven't started yet"
continue
fi
#Read the line for a closing bracket
for ((i=0; i<${#line}; i++)); do
#If we've reached this for loop started gets set to true
#Because we've started parsing a function
if [ "${started}" == "false" ]; then
started="true"
#Record the line number since it's the start of the relevant part of the function
startLineNum=$curLineNum
#echo "starting function parsing... line num is ${curLineNum}, startLineNum is ${startLineNum}"
fi
local char=${line:i:1}
case $char in
"{")
#Got a new opening bracket, push to the stack
#echo "Got an opening bracket: $char"
CurlyBracketStack+=$char
;;
"}")
#Got a non-matching bracket, shouldn't happen
#Since we are only doing curly brackets I guess the array is not
made a proot alternative that doesn't use ptrace, curious if it holds up for anyone else
/r/termux/comments/1vj23hs/made_a_proot_alternative_that_doesnt_use_ptrace/
https://redd.it/1vj4852
@r_bash
agent-history listed on awesome-zsh-plugins; new v1.2.3 performance update cuts scan times down to <90ms in tests
https://github.com/aaronbronow/agent-history
https://redd.it/1x250f6
@r_bash
Alias for Safety? Creating Alias for more than one word?
/r/linux4noobs/comments/1x86fbl/alias_for_safety_creating_alias_for_more_than_one/
https://redd.it/1x86fhu
@r_bash
Tinybackup: a tiny Kopia backup wrapper
For all those who want simple backups of their machines, I have created a tiny bash wrapper around Kopia: https://github.com/bderenzo/tinybackup
From a single minimal config file, it handles repository setup, retention, ignore rules and pre/post backup hooks, etc.
It can back up to a local disk, SFTP, S3 or any rclone remote, and lets you browse snapshots through CLI, a mount point or the Kopia web UI.
https://redd.it/1x630n8
@r_bash
Many things could go wrong with this script and leave a running process, how would you recommend fixing this?
#!/usr/bin/env bash
function main() {
# Phase 1: Setup and Run Dev Server
printf "%s\n" "Starting development server..."
cd "$HOME/Desktop/my-project-1" || exit 1
# Run the dev server in the background
rm -rf coverage dist && npm run lint && npm run coverage && npm run test && npx tsc || exit 1
npx tsx watch --env-file=.env.development src/index.ts > "/tmp/server.log" 2>&1 &
DEV_PID=$! # Store the Process ID of the 'dev' server
# Monitor for "server is listening"
printf "%s\n" "Waiting for server startup message..."
while ! grep -q "Server is now listening" "/tmp/server.log"; do
printf "%s\n" "Server not yet ready. Still waiting..."
sleep 1 # Wait 5 seconds before checking the log again
done
printf "%s\n" "SUCCESS: Server is listening. Proceeding to Phase 2."
# Phase 2: API Call and Wait
printf "%s\n" "Executing API call..."
rm -rf /tmp/test_app && curl -X POST http://localhost:3003/job/node/express/basic/generator
# Monitor for "downloading..." message in logs...
printf "%s\n" "Waiting for download completion..."
# Wait for the download confirmation
while ! grep -q "downloading docker container files completed successfully" "/tmp/server.log"; do
printf "%s\n" "Waiting for download confirmation..."
sleep 1
done
# Phase 3: Cleanup
printf "%s\n" "Shutting down services..."
kill ${DEV_PID} # Use the stored PID to gracefully stop the server process
printf "%s\n" "Moving into generated code..."
cd "/tmp/test_app" && npm install && code "/tmp/test_app" && cd "$HOME" || exit 1
}
main "$@"
Add and subtract times
How can I use date to add and subtract times? I want to ignore time zones and just change the time. For example date -d "21:00:00 +02:02:30 -01:10" +%"T" should show 23:01:20.
https://redd.it/1v98u10
@r_bash
A small bash tool for sandboxing AI coding agents on linux
/r/CLI/comments/1x34iix/a_small_bash_tool_for_sandboxing_ai_coding_agents/
https://redd.it/1x34prg
@r_bash
Vi mode history isn't consistent
In vi mode up and down arrows goes through history and puts the cursor at the end of the line but j and k puts it at the beginning. They are all bound to previous-history and next-history commands so why is it different? Can I make j and k work like up and down?
CTRL+p and CTRL+n are also bound to previous-history and next-history but it's not going through history it's going through a list of all commands it can find.
How can I make everything the same as up and down arrows?
https://redd.it/1vafuk7
@r_bash
Almost a year of work—how are these? Using only rofi and completely written in bash.
https://redd.it/1vclxa1
@r_bash
Can AI actually write production-ready scripts end-to-end without human intervention?
/r/linuxquestions/comments/1x2lto3/can_ai_actually_write_productionready_scripts/
https://redd.it/1x2lu1q
@r_bash
Linux Interview Question
Today I had a mock interview with a senior Linux administrator, and he asked me a question that completely caught me off guard:
"Can you collect CPU, Memory, and Disk usage in a Bash script without using top, free, df, or any external commands?"
My immediate answer was No.
Honestly, I've been working with Linux for years, but I've always relied on standard commands and monitoring tools to troubleshoot systems. I never stopped to think about where those commands actually get their data from.
The interviewer then gave me a hint about the /proc and /sys filesystems. That completely changed my perspective. I realized these commands are just reading data that the kernel already exposes.
But then came the follow-up questions, and once again I was stuck:
Is reading directly from `/proc` and `/sys` the correct approach?
How would you calculate CPU utilization using /proc/stat?
How would you determine memory usage from `/proc/meminfo`?
How would you calculate filesystem usage without relying on df?
I found this really interesting because it tests your understanding of Linux internals rather than just your ability to use commands.
Has anyone here been asked similar questions in Linux SysAdmin, DevOps, or SRE interviews? I'd really appreciate any explanations, learning resources, or examples on how you'd answer these follow-up questions. It help me for my preparation for Linux interviews
https://redd.it/1veg8ir
@r_bash
I built a visual game entirely in pure Bash — here is the demo and full source code!
Hey everyone,
I wanted to show what's actually possible using just pure Bash—from custom terminal graphics and animations to game logic.
I've been working on a project called Alchemon, a game written completely in Shell script that pushes terminal visual output to its limits. No external heavy frameworks, just raw CLI magic!
📹 Watch the gameplay demo on YouTube: \> https://www.youtube.com/watch?v=yFOpOPtk-Sc
💻 Check out the source code on GitHub: \> https://github.com/mrugaladamian/alchemon
Feel free to clone it, test it out, or drop any feedback/ideas. Hope you enjoy it!
https://redd.it/1vg6690
@r_bash
mirror-repo: Auto-sync Gitlab and Github repositories
https://redd.it/1vhux6o
@r_bash
strictly needed
if [ -z $CurlyBracketStack || "${CurlyBracketStack: -1}" != "${brackets[$char}" ]]; then
#echo "bad bracket match: $char"
return 1
#Got a matching bracket, pop from the stack
else
CurlyBracketStack=${CurlyBracketStack%?}
#echo "stack is now ${CurlyBracketStack}"
#if the stack is now empty, the function is bounded
if [ -z $CurlyBracketStack ]; then
#store the ending line number and set bounded to true
bounded="true"
endLineNum=$curLineNum
#echo "I think this is the end of the function, ending on ${endLineNum}"
fi
fi
;;
esac
done
if [ "${bounded}" = "true" ]; then
#echo "Breaking the loop"
break
fi
done < "${inputFile}"
if [ $started == "false" ]; then
echo "Could not find ${funcName} in ${inputFile}"
return 1
fi
#Print the section of the file
bat "${inputFile}" --line-range $startLineNum:$endLineNum "$@"
return 0
}
https://redd.it/1vi91ip
@r_bash
Shell poetry
1. for for in for; do eval "$for $for in $for; do echo \$$for; done"; done
2. do=for; eval=do; for=in; in=echo; echo=eval; foo=done; done=foo; $echo "$do $eval $for echo; $eval $in $done; $foo"
3. for=$(for do in for do in echo \; do echo \$do \; done; do echo $do; done); echo $for; eval $for
4. for=for; for do in in; do echo in; eval "for do in echo; do echo for \$do do $for \$for \\$for \\\$for \\\\$for; done"; done
https://redd.it/1viiar1
@r_bash
Use alias from ssh
I can do `ssh $HOST` then use `myalias $PATH` to use an alias set in .bashrc (and .bash_profile does `source ~/.bashrc`). But I can't do `ssh $HOST 'myalias $PATH'` it can't find myalias.
How can I use the alias and use $PATH that's on the server?
https://redd.it/1vjaemx
@r_bash
return and exit in potentially sourced script
Disclaimer: Yes, I am doing things bash scripting isn't meant for. No, I won't let you talk me out of it.
I have a script that might be run directly or might be sourced; so to exit out of it I have to either `return` or `exit` accordingly.
The simple "is_sourced" test I found is `(return 0 2>/dev/null)`.
obviously this invites the following structure:
```
if (return 0 2>/dev/null); then
return "$exitcode"
else
exit "$exitcode"
fi
```
however that feels like extra work when I can just
```
return "$exitcode" 2>/dev/null
exit "$exitcode"
```
Someone tell me what could possibly go wrong?
https://redd.it/1vjotxj
@r_bash