Masthash

#Bash

For all youse fans of The #Replacements, #Bash&Pop, #Perfect and #CowboysInTheCampfire fans:

The one and only @tommy_stinson@twitter.com is appearing on @WBFOTheBridge@twitter.com Saturday at 9 a.m., in an interview we taped last week.

Hear his thoughts on his new album, tour, and re-release of Tim.

just automated a tedious documentation process at work through a #bash script and some #markdown and currently feel like a god ama

During the #ansible community day, I was asked about my terminal.

Well, my overall theme is coming from the awesome Catpuccin project. My prompt is made with Starship and the initial "fetch" is small tool, written in Go, mostly for myself. And the font is FiraMono Nerd Font.

Here are the links to said projects:

- https://github.com/catppuccin/catppuccin
- https://starship.rs/
- https://github.com/dschier-wtd/cutefetch
- https://www.nerdfonts.com/font-downloads

#bash #prompt #theme #looks #terminal #shell #linux #opensource #showcase

A terminal, showcasing a cute "fetch" at the beginning, made out of a bunny, and some system information like the logged in user, the operating system and the time.

The prompt is showing additional information like the git branch, last command result and versions of the runtime for a project directory.
Gianluca
19 hours ago

Just released a new version of #bash profile switcher. If you want to try it out and give me feedbacks I will appreciate it. #linux #scripting
https://github.com/gianluca-mascolo/bash-profile-switcher/releases/tag/0.2.0

sbug
20 hours ago

Just updated to #Mastodon v4.2.0

Now it's time to create a #bash #script I've been waiting to do.

Jürgen
22 hours ago

grade n artikel gefunden. heute ist im #urlaub nochmal #weiterbildung dran - und @coresec : nicht #mojolang ... #bash ist angesagt!

AskUbuntu
1 day ago
clonbg
1 day ago

Script en bash que comprueba si hay internet y ejecuta unos programas #Linux #Scripts #Bash https://myblog.clonbg.es/#/script-autostart https://clonbg.es

Script en bash que comprueba si hay internet y ejecuta unos programas #Linux #Scripts #Bash https://myblog.clonbg.es/#/script-autostart https://clonbg.es
Robert Buchberger
2 days ago

Anyone out there daily driving #nushell? It looks super neat, solves a lot of my frustrations with #bash and #zsh. Still under heavy development though, is it ready?

#linux #software #foss

It feels really weird using environment variables that are not even 1 day old yet.

#eza #bash #zsh

Sometimes it's easy to forget how much the #linux #foss #opensource community innovates so quickly and it really is person to person where things get done.

github commit showing new environment variable declaration merged 17 hours ago on project eza.
Lucy 🏳️‍⚧️ #BLM
2 days ago

You don't need quotes that often when making filenames or typing file paths:

#programming #bash

dewomser
2 days ago

#Bash Tipp
nach einer Änderung in
~/ .bashrc
will man ja die Änderung gleich ausprobieren. So gehts :
. ~/.bashrc

Verdammt! Was ist noch mal .bashrc ?

OSTechNix
2 days ago
AskUbuntu
2 days ago
Scott Williams 🐧
3 days ago

Here's a fun #bash script pop-quiz for you:

[[ true == false ]] && myvar=2 || ( myvar=0 ; myvar=$(( $myvar + 1 )) )

echo $myvar

Bonus points if you can say why :-)

AskUbuntu
3 days ago

cli commands to fetch and set ubuntu settings? #bash #scripts #shortcuts

https://askubuntu.com/q/1486328/612

@poppyhaze No, I'm thinking about #bash and #fish!

https://fishshell.com/

Biason::Julio::new();
3 days ago

Dear Lazyfedi:

What does && without any following do in #Bash?

For example, is there any difference between

command1 &&
command2

and

command1 && \
command2

?

dewomser
3 days ago

#Linux #Bash Einzeiler Tipps:
Mediatags aus Firefox auslesen zB von youtube

qdbus org.mpris.MediaPlayer2.plasma-browser-integration /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Metadata

AskUbuntu
3 days ago

Exit cron job after launching program #bash #cron

https://askubuntu.com/q/1486255/612

Tekchip
4 days ago

Oh boy, I did a thing, again. Not often enough TBH. I'm kind of lazy. Anyway...

Game Ownership in 2023. Or How
To Backup your GOG Game Collection.
https://blog.brockh.at/video-game-ownership-in-2023/

#videogames #blog #GOG #backup #python #bash #linux #linuxgaming

robrich
4 days ago

https://dev.to/lucassperez/bash-history-inside-docker-container-553g - want to keep #bash history inside #Docker? Set an environment var to point to a file inside the app folder, maybe map a volume to a `.dotfiles` folder, and keep it there. Great technique https://github.com/lucassperez and thanks for the dotfiles repo: https://github.com/lucassperez/dotfiles/

Benedikt Ritter
4 days ago

Feeling lucky today. So tonight I‘m going start migrating https://github.com/britter/dotfiles to home-manager #nixos #homemanager #linux #dotfiles #bash #shell

Club de TéléMatique :verified:
4 days ago

An A-Z Index of the Linux command line: bash + utilities:
https://ss64.com/bash/ #linux #bash #doc

4 days ago

Aventuras y desventuras en el planeta Terminalia / la Shell ... de la mano de herramientas GPT que nos facilitan la tarea.

Vamos a mover/copiar ficheros en nuestro sistema, ... de otra forma ?

#shell
#bash

- https://github.com/TheR1D/shell_gpt

- https://openai.com/blog/gpt-3-5-turbo-fine-tuning-and-api-updates

https://fediverse.tv/w/8DnWVw9qYPoFzTN68ygzMc

AskUbuntu
4 days ago

Unable to resume from suspend due to zsh as default shell - why? #bash #suspend #powermanagement #zsh

https://askubuntu.com/q/1486141/612

clonbg
4 days ago

Grabar una iso en un Usb desde la terminal con dd #Linux #Terminal #Bash https://myblog.clonbg.es/#/grabar-dd https://clonbg.es

Grabar una iso en un Usb desde la terminal con dd #Linux #Terminal #Bash https://myblog.clonbg.es/#/grabar-dd https://clonbg.es
Teri Radichel
5 days ago

Using the Lambda Runtime Interface Emulator With a Custom Bash Runtime
~~
ACM.307 Revisiting the RIE with a revamped Arm container for Lambda
~~
Run #bash in a #container in an #AWS #Lambda function and test it on your #localhost

https://medium.com/cloud-security/using-the-lambda-runtime-interface-emulator-with-a-custom-bash-runtime-f3bd77d61a8c

AskUbuntu
5 days ago
Armin Hanisch
5 days ago

Wer ein kleines Beispiel sucht, warum sich jemand mit der Kommandozeile befassen sollte und wie produktiv das Konzept der Verkettung von Befehlen ist: zerlegt den Barden.
https://www.arminhanisch.de/2016/07/shakespeare-und-die-shell/

#Scripting #Shell #Bash #TextTools #CmdlineDataScience

Open Source Pro
5 days ago

"Der `find`-Befehl ist ein vielseitiges Tool unter Linux! Verwende `find` zusammen mit dem `-exec`-Flag, um Befehle auf gefundene Dateien anzuwenden. Zum Beispiel: `find /pfad -name '*.txt' -exec rm {} \;` entfernt alle Textdateien im angegebenen Pfad. Mächtig und effizient! #Linux #Bash #OpenSource"

AskUbuntu
6 days ago

Adding chapters to mp4 using bash script and ffmpeg #bash #scripts #ffmpeg #videoconversion

https://askubuntu.com/q/1486030/612

Teri Radichel
6 days ago

Adding Error Handling to Bash Custom Lambda Runtime
~~
ACM.306 Using Bash trap to capture and handle errors in bash scripts
~~
#lambda #bash #runtime #trap

https://medium.com/cloud-security/adding-error-handling-to-bash-custom-lambda-runtime-29d3f1c94441

AskUbuntu
6 days ago

Why is my .bashrc caching curl when using as command substitution $(curl -s http://someurl.com)? #commandline #bash #curl

https://askubuntu.com/q/1486017/612

Celfred
6 days ago

Je relis mon .bashrc et ceci me rend bien des services car j'oublie souvent tous les paramètres pour extraire des archives en ligne de commande. Là, je tape extract nom-de-l-archive et c'est réglé :)

extract () { if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2…

Note:
https://shaarli.demapage.fr/shaare/4YKJ3w

#bash #ligneDeCommande #commandLine #linux #Shaarli2Mastodon

AskUbuntu
1 week ago

grep Not Displaying Results Due To Apparent Garbage Characters In File #bash

https://askubuntu.com/q/1485970/612

Teri Radichel
1 week ago

Custom Bash Runtime for Lambda Container
~~
ACM.305 Using AWS base images for a container that runs a custom Lambda runtime
~~
#bash #container #lambda #runtime

https://medium.com/cloud-security/custom-bash-runtime-for-lambda-container-bec64ab33582

AskUbuntu
1 week ago

Running OpenFoam command: paraFoam -> Error 420: paraView: not found #commandline #bash #bashrc

https://askubuntu.com/q/1485971/612

Teri Radichel
1 week ago

Custom Lambda Runtimes
~~
ACM.304 Overview of a custom Lambda runtime to execute bash scripts deployed in a container in Lambda
~~
#Lambda #custom #runtime #bash #shell #script #container

https://medium.com/cloud-security/custom-lambda-runtimes-6da9977eabfe

Open Source Pro
1 week ago

"Der `find`-Befehl ist ein mächtiges Werkzeug in der Linux-Kommandozeile. Mit `find . -name "*.txt"` durchsucht man das aktuelle Verzeichnis und seine Unterverzeichnisse nach Textdateien. #Linux #Bash #Kommandozeile"

Translation: "The `find` command is a powerful tool in the Linux command line. Using `find . -name "*.txt"`, you can search the current directory and its subdirectories for text files. #Linux #Bash #Commandline"

Want to make a career change to #IT, but not sure where to start?

Read Adam Stegienko’s path to become a #DevOps Engineer; from #finance to #SEO, using #python, #Linux and tools like #kubernetes, with the help of Develeap training and Linux Professional Institute (LPI) certification!

Achieve your goals next: https://lpi.org/7qfs

#python #git #tech #LPI #ITCertification #opensource #FOSS #SEO #VBA #excel #develeaps #jenkins #terraform #bash #kubernetes #stackoverflow

AskUbuntu
1 week ago

./docker-build.sh: ./mvnw: /bin/sh^M: bad interpreter: No such file or directory #commandline #bash #scripts #2204 #shebang

https://askubuntu.com/q/1485905/612

dewomser
1 week ago

#Linux / #Bash 1-Einzeiler + imagemagick

Titel vom Bild am unteren Rand reinschreiben

https://gist.github.com/dewomser/108e51142318b24721cd08a5ea15b7ab

Bildunterschrift ins Bild integriert
AskUbuntu
1 week ago

Why is gdbus call not working with root user? #bash #gnome #keyboardlayout

https://askubuntu.com/q/1485798/612

AskUbuntu
1 week ago

Loop through file extension Annotate add EXIF Rename and Copy #commandline #bash #scripts #convert #annotation

https://askubuntu.com/q/1485733/612

ДевоПес
1 week ago

Дуже часто одразу після заходу на сервер перевіряю перелік процесів. Просто звичка, але це допоможе виявити сторонні процеси або аномалії
ps -axuwf
#Linux #bash

AskUbuntu
1 week ago

In Ubuntu is there a way to configure PS1 so that it does not update the window title? #commandline #bash

https://askubuntu.com/q/1485703/612

AskUbuntu
1 week ago

I once spent a pleasant several hours (not sarcastic) writing a #bash #script to test my home internet connection every 15 seconds (it was so bad, bad wire from pole)

Then ran the script for 8 months.

Finally the connection improved and I turned that old computer off.

Yesterday I had new troubles so I tried to turn on the computer and it won't even power on - ancient thing, dead.

Now I'm sad I lost my script, excited that I get to rebuild, but sad I have no old computer to run it on.

⚠️CYBER⚠️katze
1 week ago

#python: that idiot that thinks they're smarter then everynyan else but actually just keeps fucking up and has no idea what they're doing and refuses to learn

#javascript: just some popular drunk guy on a party

#typescript: javascript's driver

#bash/#zsh/generally posix shells: old guy that yells "get off my lawn!"

#php: nice old guy who tries to be accepting and keep up with society

#rust: that one genius who is also amazingly reliable and yeah (definitely not me)

#nushell: idk but they're probably cute

#java: old person with i-am-rich-complex

Yann Büchau :nixos:
1 week ago

Awesome talk at #NixCon by Luc Perkins from Determinante Systems about rewriting :nixos: NixPkgs' standard builder in #NuShell (instead of #bash):

https://www.youtube.com/watch?v=QwElUltNsq0

#nkx #NixOS #nixpkgs #NixCon2023

dewomser
1 week ago

#Bash Tipp:
$(<file) ist das gleiche wie $(cat file), nur schneller

stirz ✅
2 weeks ago

Morning, #fediverse

To all people doing #selfhosting or running some #homeserver on #Linux

I am keen to know how you are handling notifications:

• E-Mails?
• PC Speaker?
• Chatbots?
• Lights?
• ...

Currently, I am tinkering around with a simple #Telegram bot which is a breeze through #BASH.

Please share how you do it in general or using which piece of software.

And boost, if you can!

Joel Bennett
2 weeks ago

What if your #readline shipped with Copilot?

I'm still not sure if this is something I need or not, but I got Microsoft's CodexCLI working (again), just so I could show it off.

This is how I want github #copilot CLI to integrate.

I *do* like the explanations the current Copilot CLI gives, but I want this in the readline because I want to be able to edit the command I get back.

#PowerShell #Bash #Zsh #PSReadline

https://i.imgur.com/8vbkF48.gif

P.S. My working fork is at https://github.com/Jaykul/ReadlineAI

A poor demo of the old CodexCLI tool in PowerShell
https://i.imgur.com/8vbkF48.gif
Philipp Bayer
2 weeks ago

No #bash command has helped me more in debugging than `which`

In nine out of ten cases when Python or R was doing something unexpected, it was because I was using the wrong installation

Andrew Woods
2 weeks ago

Are there particular challenges you have - or maybe a function you wish you had - when shell scripting using dates/times ?

#Bash #ShellScript
#CommandLine

Martin Schmitt
2 weeks ago

Die gefürchtete #OCPP-1.6-Implentation in #Bash ist öffentlich und ich beginne zu verstehen, warum Ladesäulenfreischaltung ein einziges Dumpsterfire ist. Alle Charger halten 24x7x365 einen Socket zur zentralen Instanz offen und die muss lückenlos deren Status tracken, in Echtzeit im Verbund mit drölfzig Roamingsystemen. So sehr ich gegen mancher Leute Girocard-Fetisch bin, ich hab keine Ahnung, wie das mit dem Laden anders skalieren soll. https://github.com/mschmitt/shocpp #Elektroauto #Elektromobilität

Agnieszka R. Turczyńska
2 weeks ago

Let me give you some words of #Linux programming wisdom.

1. You can write quite a big project in #Bash.
2. But this is not a good idea. You will spot problems because of how #shell programming works.
3. However, those problems could be solved (or rather worked around) by (ab)using global variables.

Happy coding!

Scott Williams 🐧
2 weeks ago

I managed to get through today without committing any more crimes against #bash, very much unlike yesterday..

https://mastodon.online/@vwbusguy/111014818717361861

artfulrobot
2 weeks ago

Heredocs vs Herestrings in #bash

When would you use one or the other? They seem functionally equivalent?

Iago Andrade
2 weeks ago

Well, I think it could be nice to talk a bit about myself, so here it goes (it is a long one, be warned)

My (still ongoing) journey from engineering to programming: Prologue
As can be seen in my profile bio, my name is Iago Andrade, and I am a Brazilian. What can't be seen there, though, is that I'm a mechanical engineer, and I have worked as a mechanical designer since 2018. This year (2023) I decided to pursue an old desire, which was to be able to work with #programming.

First contact
From the very first year at university, I fell in love with programming, when we were introduced to #C. Most of my friends were not really interested in that, and thought it was too difficult, but I was fascinated by the possibilities of what could be done with it.
At first, we used it mostly to solve dificult mathematical problems through iterative process, but my curiosity led me to learn more than just what was taught in classes. We were also later introduced to MATLAB and EES, and I even learned a bit of #Python in order to help a friend of mine.
But as the course became more and more time consuming, I started to drift away from that passion, and focus more on the other disciplines, and only sparingly did I delve into anything related to programming.

First job
As I graduated, I soon got a #job in mechanical design, modeling industrial equipment and parts and its drafts for production. As I had little time for studying, programming was put aside for a while, and all the focus was put into this job.
I learned a lot at this job, and managed to build a lot of resources for accelerating, and even automating tasks, and that kept me reminded of how much I liked to solve problems like these. I even got to the point of learning some #bash script in order to automate the creation of folders in the company's server (which did not end up very well, due to the lack of some quotes hehe). Though the script caused some problems, it was solved in the end (and I learned the important lesson of debugging everything very thoroughly).

Reigniting an old passion
At some point between then and now, I learned of the existence of a "new" game engine called #Godot. I had never made any #games, and had never used a game engine before either, but I had had some contact with #FOSS (free and open source softwares), like #blender and #inkscape, and that one caught my attention, since I had always wanted to create games. Since it was free, super lightweight, I decided to give it a go. It felt so good to learn that tool, and programming in it reminded me of how much I liked to code.
Back then, a friend of mine was also interested in making a game, and he wanted to be more focused on the story part of it, which was perfect since I wanted to focus on the programming and possibly the art and music for it. We started to work on the idea, got a ton of references, and started building the overall scope and story, until one day we lost momentum and just couldn't get back to it. Our jobs were sucking too much energy, and we decided to put it aside until we had more time to do it properly.

#SQL and the leap of faith
After some more years of working with 3D modeling, the company where I was working decided to implement an ERP system. The problem was they didn't have anyone from the inside who was qualified for some of the tasks that would appear, and they tasked me with dealing with those problems.
I had never worked with an ERP system, but had some idea of how #databases worked, and that helped a lot in making some decisions early on (like not entrying all data manually). I had to learn how to bulk clean old data from another system they had used before, which had been fed by many different people, with a lot of mistakes and inconsistencies.
After that, I had to import all that data into the system, and I decided it was time to learn SQL so I could query the database properly when I needed information. And that once again triggered my interest in programming, leading to my decision to make new templates for the engineering team.
These templates used programming for automating some of the tasks, in a language specific for the modeling software,reducing many of the steps in the project pipeline, and making it easier to input new equipment in the system.
As I became more and more #tired of some problems at work, and got more interested in programming again, I made the decision of focusing in relearning the languages I had contact with, and while searching for resources, I was informed that #Harvard offered this course online, called #CS50
For a few months I tried, and was unable to #study in my spare time. So ultimately, I decided to #quit my job, finish CS50, and start a career in programming.

Paying the #bills
With only the final project from the course left, money was running short, and bills were still appearing, so I had to start looking for jobs, and I ended up getting another job in mechanical design. The difference now is that it is much closer to home, so I will be able to finish my final project on my spare time, and keep looking for #junior roles in programming.

Epilogue: The Final Project
Since this toot is ridiculously long already, I may as well talk about the final project for whoever got to this part haha
The idea for the project is to mix a bit of #gamedev with #webdev, making a site with three main areas containing mini-games in three different styles, from #ASCII to one with actual graphics. If all goes well, I also wanted to enable players to get a score, and keep that in a database, if the player so desires. #Backend is being done in python with #flask, #frontend is using templates from flasks #jinja, but mostly plain #HTML #CSS and #javascript

Andrew Woods
3 weeks ago

Bash Tip:

There are 2 ways to create a function in Bash

function hello {
# your code here
}

or

hello() {
# your code here
}

using the function keyword and the empty parentheses is rendundant

#Bash #ShellScript

Joseph Scott
3 weeks ago

Too often I think I'll write this little tool in bash. I always come to regret it. Some times it takes longer than others to come to that conclusion, but the conclusion always ends up being the same. #bash

@chrys My daily use command line productivity tools are:

1. #readline support. C-a, C-e, C-r and tab-completion will save you h o u r s (M-f, M-b are second-tier here)

2. less and tail

3. #grep

4. #ssh and scp *esp with keys*

5. #bash scripting *on the command line*. that is, writing this in a single line: "while true; do CMD; sleep 1s; done" (more general and less fragile than `watch`)

6. cut and tr (for simple "parse every line of output" situations)

7. #sed and #awk (for hard ones)

WesMason
3 weeks ago

I got someone in the know checking my code for bugs.
#coding #bash #codingbugs #lanternflies #linux

It's FOSS
3 weeks ago

Here's how to check if a file/directory exists in Bash.

https://itsfoss.com/bash-if-file-exists/

#bash

Andrew Woods
3 weeks ago

who has the best dotfiles?

You can choose multiple. Please include what you like about them AND Include links to the repos

#bash
#linux #MacOS #Mac #DotFiles
#CommandLine

Reviewing a #linux #bash #script written by a younger #developer. It uses getopts, read and #sed.

The ancient rituals persist!

Bryan Redeagle
1 month ago

FusionPBX's handling of SSL certificates is very clunky and manual, and I hate it. Time to dust off my bash scripting and write a better way.

#FusionPBX #bash #OpenSource

this is the most useful website i’ve found in a long time.

#bash PS1 generator https://omar.io/ps1gen/

Geekman
1 month ago

I briefly had a blog back when I was a Mac OS X Server admin (~15 years ago... sigh). It was a miserable failure but some of the tips and tricks might be worth revisiting today.

In the Terminal and SSH, I prefer listing directories using ls -Gal (colourized output, hidden files, long format), but I really hate typing it!

Create an alias ("list" in my case) in your #bash or #zsh profile to make life easier and less error-prone.

alias list='ls -Gal'

#macOS #Terminal

https://linuxhint.com/configure-use-aliases-zsh/

Matt Stenson
1 month ago

xargs saves the day 🔥.

We’ve all deleted files in a folder using rm *. But sometimes it doesn't work!

#bash #linux #commandline

Jay
1 month ago

After sticking with #bash forever, I think I'm gonna try switching to #FishShell. Any tips?

Felix Palmen 📯
1 month ago

Time for cleanup after identifying two "interesting" issues:

1.) #FreeBSD ports come with a Templates/config.site file which is normally used by #GNU #autoconf, containing quite a lot of "cache variables" so autoconf can avoid running the actual tests. Nice, but completely wrong when targeting #Linux. So, add an empty "CONFIG_SITE=" variable to every linux port, and suddenly I can also remove some explicit cache variables again 🙈

2.) I'm building the "native" toolchain for #Linuxulator --with-sysroot=/compat/linux, which makes sure the linker reliably finds startup files and system libs, without stuff from FreeBSD base interfering. BUT: This completely breaks when some explicit lib path to /usr/lib or /usr/lib64 is added (and many build systems will do that), because sysroot doesn't apply here. Therefore, add wrapper scripts around gcc and g++ filtering out any "-L/usr/lib" or "-L/usr/lib64" argument 🙈 with that, Linux #bash builds without any patches! 🥳

Now, waiting for builds.

Felix Palmen 📯
1 month ago

And now, we have a working #Linux #bash running in #FreeBSD's #linuxulator

Which also finally makes the "ldd" script installed by #glibc work 😎

Ok, enough for today 😉

https://github.com/Zirias/zfbsd-ports/blob/linux/shells/linux-bash/Makefile

António Domingues
1 month ago

@b0rk_reruns sometimes #bash feels like magic. The syntax is imo very impenetrable but it is just so powerful

Changelog
1 month ago

The CLI is a super efficient way to use a computer, but discovering how to use it well is a big challenge.

@jerod tells his history with the `history` command and concludes:

There’s so much efficiency gains you could have if you just have someone tell you “Here’s how to do it.”

#linux #unix #cli #commandline #shell #terminal #history #bash #zsh

🎥 https://youtu.be/RItiJrEeC70

Andrew Woods
1 month ago

For your shell scripts — what are you using for testing them?

#Bash #CLI #ShellScript #testing

CCC Freiburg
1 month ago

@b0rk most starters like things like #tmux - #bash-insulter (its fun) and #cmatrix and the obvious
telnet towel.blinkenlights.nl
and for people which go the extra mile, either #adb with #scrcpy for android fun or the limitless options of #yt-dlp
(spice up your music collection with some yt-dlp -x <LINK>
or choose smaller / bigger quality with yt-dlp -F <LINK> ... so much more fun tha any limited and fastly outdatet gui/addon)

Roni Laukkarinen
2 months ago

So proud of my disk size monitoring script, so I'm just going to share it here as-is:

#!/bin/bash
# diskspace.sh
# Set up the mountpoint
MOUNTPOINT="/mnt/somethingsomething"

# Get disk usage and total
DISK_USAGE=$(df -hk | grep "$MOUNTPOINT" | awk '{print $3}')
DISK_TOTAL=$(df -hk | grep "$MOUNTPOINT" | awk '{print $2}')

# Convert from block sizes to GB
DISK_USAGE_GB=$((DISK_USAGE / 1024 / 1024))
DISK_TOTAL_GB=$((DISK_TOTAL / 1024 / 1024))

# How much is allowed to be left
DISK_GB_LIMIT="8"

# How much is left
DISK_GB_LEFT=$((DISK_TOTAL_GB - DISK_USAGE_GB))

if [ "$DISK_GB_LEFT" -lt "$DISK_GB_LIMIT" ]; then
echo "Less than ${DISK_GB_LIMIT} GB left! Only ${DISK_GB_LEFT} GB left!"
else
echo "There is still ${DISK_GB_LEFT} of ${DISK_TOTAL_GB} GB left. No need to be alarmed as the alarming size is ${DISK_GB_LIMIT} GB."
# Your heartbeat curl here:
curl https://example.com/endpoint;
fi

Set up a cronjob:

# Disk size heartbeat
*/3 * * * * bash /path/to/diskspace.sh >/dev/null 2>&1

#MastoAdmin #Bash #Scripts #Linux #Server #Code

scy
2 months ago

@awoodsnet Getting return codes out of individual components of pipes.

Making people understand what bashisms are and that they can’t be testing scripts with a shebang of #!/bin/sh with just bash.

Getting structured data out from stuff that’s running in subshells, like setting variables from something in a `| while read` loop.

#bash #shell #scripting

Andrew Woods
2 months ago

what do you wish was easier about Bash scripting?

#Bash #ShellScript #CLI

gemma lynn
2 months ago

i just magically muscle-memoried myself into #vim-style navigation in a #bash shell prompt and i have no idea how

help how do i do it again

#linux

Tim Penhey 🇳🇿
2 months ago

Yet again having to google the bash syntax for a 'for loop'.

#bash

Amadeus Paulussen
2 months ago

Do you prefer #bash or #zsh and do you use #ohmyzsh? #linux #commandline #terminal

TIL that in Bash, the control operator `&` (to background a task) is akin to `;` and is used as a command list separator in the same way. A one-liner to background many tasks would look like:

```
for i in 1 2 3 ; do echo $i & done
```

Previously I thought it was some special indicator, separate to the `;` and used in a different way. I only learned the similarity because `echo $i & ;` is an "unexpected token" syntax error in Bash 5.0. Bash 5.1 doesn't error out in the same way. #bash

@aral @miklo thx.

For Same does for a lot of of other things:
I'd love to get #FSF / #GNUtils out of my tech stack just for them letting #Stllman back in but alas I'm kinda forced to work with #bash and #nano and stuff...

https://www.youtube.com/watch?v=R2SKenHRhMg

Blake Patterson
2 months ago

As people are asking, here's the drill I went through to configure my Mac to allow my Apple IIe (and other vintage systems around the room) to "dial in" to it via WiFi232 or other WiFi modem devices.

https://bytecellar.com/2022/11/28/configure-your-mac-to-allow-vintage-computers-to-dial-in/

(I've just updated the post, to address a little snag I encountered, caused by a recent macOS update.)

#IRC #vintagecomputing #retrocomputing #vintagecomputers #AppleII #Apple #vintagetech #tech #hardware #terminal #UNIX #irssi #blog #zsh #bash #howto

Roni Laukkarinen
2 months ago

If anyone is wondering how my #MementoMoriSocial nightly upgrade process works, here's the long drill.

If mastodon main branch has any prominent updates (usually I do this when a release happens in stable versions or when I know there's something good in there):

1. Backup (things obfuscated with XXXX here for security)

```bash
# Log in as postresql user
sudo su postgres

# Dump database
sudo -u xxxxxx pg_dump --verbose -U xxxxxx -F c xxxxxx > /var/lib/postgresql/mastodon_production_`date +\%Y\-%m\-%d\-%H`.tar

# Move backupped database file to external NAS
mv /var/lib/postgresql/xxxxxx* /mnt/xxxxxx

# Exit from postgresql user
exit

# Log in as mastodon
sudo su mastodon && cd $HOME/live
```

2. Test locally. First go to local mastodon repository (pop_os /opt/mastodon):

```bash
# Log in as mastodon
sudo su - mastodon

# Go to test dir
cd /opt/mastodon

# Stash tests and changes
git stash

# Go to https://github.com/ronilaukkarinen/mastodon/tree/main and Sync fork with main
# Get upstream from mastodon/mastodon
git fetch --tags upstream

# Pull changes
git pull

# Create new branch for new version based on fresh main/tag with date:
git branch mementomori-social-mods-4.1.4-nightly-20230707

# Go to that branch
git checkout mementomori-social-mods-4.1.4-nightly-20230707

# Test without any changes (Vanilla Nightly)
bundle install && rm -rfv public/packs yarn install && RAILS_ENV=production bundle exec rails db:migrate && RAILS_ENV=production bundle exec rails assets:precompile

# See it works and implement own changes from my own fork

# Rebuild and test changes locally
bundle install && rm -rfv /opt/mastodon/public/packs && yarn install && RAILS_ENV=production bundle exec rails assets:precompile

# Commit to fork
git commit --no-verify -m ''

# Update version to newest branch, for example: GITHUB_REPOSITORY=mastodon/mastodon/compare/main...ronilaukkarinen:mastodon:mementomori-social-mods-4.1.2-nightly-20230703
nano .env.production

# Done! Now it's easiest just to merge the new upstream to my fork from now on
```

If I make changes to #MastodonBirdUI or the fork, I do this drill:

1. Pull changes from Mastodon Bird UI repo, implement and test:

```bash
# Log in as Mastodon and go to the test dir
sudo su mastodon && cd /opt/mastodon

# Download the CSS file for single column layout
wget --no-cache https://raw.githubusercontent.com/ronilaukkarinen/mastodon-bird-ui/mastodon-nightly/layout-single-column.css -O app/javascript/styles/mastodon-bird-ui/layout-single-column.scss

# Download the CSS file for multiple column layout
wget --no-cache https://raw.githubusercontent.com/ronilaukkarinen/mastodon-bird-ui/mastodon-nightly/layout-multiple-columns.css -O app/javascript/styles/mastodon-bird-ui/layout-multiple-columns.scss

# Replace theme-contrast with theme-mastodon-bird-ui-contrast for single column layout
sed -i 's/theme-contrast/theme-mastodon-bird-ui-contrast/g' app/javascript/styles/mastodon-bird-ui/layout-single-column.scss

# Replace theme-mastodon-light with theme-mastodon-bird-ui-light for single column layout
sed -i 's/theme-mastodon-light/theme-mastodon-bird-ui-light/g' app/javascript/styles/mastodon-bird-ui/layout-single-column.scss

# Replace theme-contrast with theme-mastodon-bird-ui-contrast for multiple column layout
sed -i 's/theme-contrast/theme-mastodon-bird-ui-contrast/g' app/javascript/styles/mastodon-bird-ui/layout-multiple-columns.scss

# Replace theme-mastodon-light with theme-mastodon-bird-ui-light for multiple column layout
sed -i 's/theme-mastodon-light/theme-mastodon-bird-ui-light/g' app/javascript/styles/mastodon-bird-ui/layout-multiple-columns.scss

# Add all changes
git add --all

# Commit change with proper commit message from Mastodon Bird UI repo, with prefix Update from mastodon-bird-ui-nightly
c 'Update from mastodon-bird-ui-nightly: Fix undefined content warning placeholder'

# Push changes to fork
git push

# Update version to Mastodon footer if necessary
nano +90 app/javascript/mastodon/features/ui/components/link_footer.jsx
```

2. Go to live and pull latest changes from fork

```bash
# Pull changes
git pull upstream mementomori-social-mods-4.1.4-nightly-20230707

# Rebuild and reload on the fly
RAILS_ENV=production bundle exec rails assets:precompile && sudo service mastodon-web reload
```

All done! The latter drill takes about 2 minutes. #MastoAdmin #bash #Linux

Matt Hodges
2 months ago

wrote some absolutely repulsive #bash to diff #mastodon post edit history

Alguém com interesse em revisar a tradução do artigo "Introdução à Linha de Comando Bash" ?

Esse projeto é sem fins lucrativos e tem auxiliado muitos estudantes de países de língua portuguesa.

https://github.com/programminghistorian/ph-submissions/issues/573

@proghist #bash #traducao

sometimes wish the #bash `history` command would also mention the date & time the command was last used...
#linux