mjgardner, (edited ) to programming
@mjgardner@social.sdf.org avatar

This is hilarious. A #Google engineer invented #zx to make command line scripting easier with #NodeJS, because at a certain point #shell scripts get too complicated and you need a Real #Programming Language.

https://github.com/google/zx/

This is exactly #Perl’s use case from thirty-six years ago. But the kids want #JavaScript everywhere and would rather it take more work to convert their ascended #Bash scripts to a vastly different syntax.

https://github.com/google/zx/issues/581#issuecomment-1516573139

#Unix #Linux #ProgrammingLanguages

nixCraft, to random
@nixCraft@mastodon.social avatar
vwbusguy, (edited ) to Bash
@vwbusguy@mastodon.online avatar

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

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

echo $myvar

Bonus points if you can say why :-)

awoodsnet, to Bash
@awoodsnet@phpc.social avatar

what do you wish was easier about Bash scripting?

scy, to linux
@scy@chaos.social avatar

The article's title: What exactly was the point of [ “x$var” = “xval” ]?

Me: "Well, cargo culting for people who don't know how to quote in the shell?"

Turns out: no. There are several good reasons why people did this, and the bugs it's been a workaround for have continued to exist into the 2010s.

If you're somewhat proficient in scripting and/or interested in history, this is an awesome read.

https://www.vidarholen.net/contents/blog/?p=1035

fell, (edited ) to programming
@fell@ma.fellr.net avatar
scy, to Bash
@scy@chaos.social avatar

Is my version of too old, or is bash simply not clever enough to know that if I do alias g='git', that g should now have the same tab-completions as git does?

nixCraft, (edited ) to random
@nixCraft@mastodon.social avatar

or press [ctrl]+[r] and type "command-you-wish to search" https://bash.cyberciti.biz/guide/Recalling_command_history

RL_Dane, (edited ) to Bash
@RL_Dane@fosstodon.org avatar

Hey ,

@ptlawrence for the solution]

I'm trying to write a script/function to convert qwerty-typed text into so I can play with it without actually converting.

It's working great, but won't pass newlines no matter what I try.

Any ideas?

Ze function:

function colemak-practice() {
while IFS= read -sn1 letter
do
echo -n "$letter" |tr "eErRtTyYuUiIoOpPaAsSdDfFgGhHjJkKlL;:nN" "fFpPgGjJlLuUyY;:aArRsStTdDhHnNeEiIoOkK"
done
}

gregorni, to programming
@gregorni@fosstodon.org avatar

My at age 15:

I'm quite proud of myself, to be honest!

celfred, to vim French
@celfred@framapiaf.org avatar

Bon, après des essais de config pour Neovim via Flathub, j'ai dû casser un truc et je m'arrache les cheveux : en console, je ne peux même plus éditer un fichier avec « vim monfichier.txt» (oui, j'ai tjrs Vim), mais ça passe avec «sudo vim monfichier.txt» 😲
Je n'ai aucune idée comment rétablir tout ça et j'y ai passé 1 soirée… (no comment…).
Si quelqu'un peut me conseiller, ce serait formidable.

thelinuxcast, to linux
@thelinuxcast@fosstodon.org avatar

I built a movie launching script in -- see how I did it. - https://youtu.be/-tKf3uV2kTc

amadeus, (edited ) to Bash
@amadeus@mstdn.social avatar

Do you prefer or and do you use ?

rml, to random

"I tried , and something I noticed was that for any simple function, takes a moment to compile, which isn't acceptable for a "

Is this really the case?? Doesn't sound right at all.

and both feel faster than , for example.

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

adamsdesk, (edited ) to Bash
@adamsdesk@fosstodon.org avatar

I must have my thoughts crossed as for the life of me I can't seem to figure out this regex in BASH using a parameter expansion.

I want to search for 2 or more dashes and then replace with one dash. Here is what I thought would work, but doesn't. Any suggestions?

string="Hello-World! command---line"
string="${title//[-]{2,}/-}"

anderseknert, to Bash
@anderseknert@hachyderm.io avatar

The only time I reach for scripts these days is when I need to call a few external commands in sequence, often with a few pipes in between them. IMHO there aren’t really that many other use cases left where some more competent scripting language isn’t a better choice. OTOH, why is that (evidently very common) use case still such a chore to do in basically any other language?

zkamvar, to ubuntu
@zkamvar@hachyderm.io avatar

Finally got my kitty terminal emulator on to take CJK input via the ibus IM. It took me an embarrassingly long time because I didn't fully understand the difference between .bashrc and .bash_profile, or that .profile exists.

I thought I had to set export GLFW_IM_MODULE=ibus in my .bashrc, but what I did not realise is that those variables only get read after the teminal emulator is launched. Once I put that envvar in .profile it worked!

https://sw.kovidgoyal.net/kitty/glossary/#envvar-GLFW_IM_MODULE

rolle, to Bash
@rolle@mementomori.social avatar

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

nev, to Bash
@nev@bananachips.club avatar

Okay aficionados: how do i tell computer "convert timestamp.png timestamp.jpg" without having to type the second filename out?

Like a shortcut for "whatever that first filename was, without the extension" so I can just do "convert timestamp.png $SHORTCUT.jpg"?

The filename is the timestamp (to the second) when it was created, so I do not know it ahead of time.

Doomed_Daniel, to random
@Doomed_Daniel@mastodon.gamedev.place avatar

Uhh.. when I have a function in Bash (let's call it fun() because it isn't), and call it like
$ fun > /dev/null
then - as expected - global variables modified in it are changed in the outer scope afterwards.
If I call it like
$ fun | tee /dev/null
they global variable with its current value is available in the function, but after the call it has the old value from before the call?!

, you drunk?

https://onlinegdb.com/g07WYP74d2

schenklklopfer, to random German
@schenklklopfer@chaos.social avatar

In einer in unter schon mal set -x gemacht und einfach nur Enter gedrückt?

Gruselig.

skinnylatte, to Help
@skinnylatte@hachyderm.io avatar

if i have a folder of .md text files that all have a date in this format: date: "2003-01-26T06:24:10Z"

in the front matter

but they are on different lines

and i want to delete the quotes from all of the files at once

what's my best approach?

(i don't know how to write regex properly)

i use sublime text, and vim, if it helps

#Help #cli #bash

JustineSmithies, to voidlinux
@JustineSmithies@fosstodon.org avatar

If all goes well with my install tomorrow I might be tempted to give a try instead of my usual trusty ?
Anyone want to chime in with reasons for and against zsh ?

profoundlynerdy, to python
@profoundlynerdy@bitbang.social avatar

With stealing everyone else's thunder, what makes a project a good fit for a scripting language OTHER than Python?

  • All
  • Subscribed
  • Moderated
  • Favorites
  • JUstTest
  • InstantRegret
  • mdbf
  • ethstaker
  • magazineikmin
  • cubers
  • rosin
  • thenastyranch
  • Youngstown
  • osvaldo12
  • slotface
  • khanakhh
  • kavyap
  • DreamBathrooms
  • provamag3
  • Durango
  • everett
  • tacticalgear
  • modclub
  • anitta
  • cisconetworking
  • tester
  • ngwrru68w68
  • GTA5RPClips
  • normalnudes
  • megavids
  • Leos
  • lostlight
  • All magazines