=== ANCHOR POEM ===
═════════════════════════════════════════════════════──────────────────────────────
If you're writing a bash script, you should never hard-code file locations.
Instead, put them in a variable at the top of your script, so they're easy to
find when people need to configure your script or move files around.
It's like a config file built INTO the script itself. Just change the
variables, they're at the top with comments.
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧══════════════════════════════════════════════─────────────────────────────┘
=== SIMILARITY RANKED ===
--- #1 fediverse/1694 ---
════════════════════════════════════════════════════───────────────────────────────
would anyone be interested in a Bash+Lua script that takes your Mastodon
archive and turns it into a folder full of .txt files?
I also made a script that spits out a random one on your terminal, if you want
that
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧═════════════════════════════════════════════──────────────────────────────┘
--- #2 fediverse/3751 ---
════════════════════════════════════════════════════════───────────────────────────
I wonder if anyone would pay me to write bash scripts for them? is there a
role that's just... bash scripter? is that what sysadmins do all day? or is
that more automation? and what the heck is a dev op? do they write bash
scripts?
or maybe writing bash scripts is the "fun" part of linux, and nobody would pay
anyone else to do it because they want to do it themselves
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧═════════════════════════════════════════════════──────────────────────────┘
--- #3 fediverse/2638 ---
══════════════════════════════════════════════════════─────────────────────────────
I really do believe that you can write any computer program you'd like with a
combination of Lua, Bash, and C.
Bash to start the program and enable updates / configuration, Lua to handle
the scripting and ordering of events, and C (or Rust) to execute performance
intensive sections. (often in their own threads)
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧═══════════════════════════════════════════════────────────────────────────┘
--- #4 fediverse/5998 ---
══════════════════════════════════════════════════════════════════════════─────────
I should conjure x11 from source. I bet they have a lot of useful utilitudes
that I can configure. I wonder if Gentoo can do it for me? nahhhhh I'll just
write my own script, it'll only take me like a couple hours per piece of
software
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧═══════════════════════════════════════════════════════════════════────────┘
--- #5 notes/environment-variables ---
═══════────────────────────────────────────────────────────────────────────────────
To edit environment variables:
~/.bashrc is for variables only accessible by the user.
/etc/profile is for variables accessible by all users.
/etc/environment is for variables accessible by anyone.
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘══════───┴╧───────────────────────────────────────────────────────────────────────────┘
--- #6 messages/264 ---
════════════════════════════════════════════════───────────────────────────────────
Don't write self documenting code! Force people to read the documentation so
they know how to use it
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧═════════════════════════════════════════──────────────────────────────────┘
--- #7 fediverse/1246 ---
═══════════════════════════════════════════════────────────────────────────────────
@user-883
hehe if I don't understand how it works it's difficult for me to use things.
My Linux friends get so exasperated with me because I'm like "cool script
gimme like 2 days to figure it out" and they're like "bro just use these
flags" and I'm like "no"
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧════════════════════════════════════════───────────────────────────────────┘
--- #8 fediverse/5168 ---
═══════════════════════════════════════════════════════════════════────────────────
this is one of the first scripts I wrote
I can't believe I put the --no-ls AFTER the argument, ha, what a noob.
ah well if it works it works and I can't refactor now because I built it into
random scripts and I'd be fixing errors all the time.
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧════════════════════════════════════════════════════════════───────────────┘
--- #9 fediverse/1762 ---
═════════════════════════════════════════════════════──────────────────────────────
This was the first bash script I ever wrote.
It's been updated a little, it was a bash alias first, but this is what it
looks like now.
Kinda shows what kinds of problems I needed to solve most.
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧══════════════════════════════════════════════─────────────────────────────┘
--- #10 fediverse/6345 ---
═════════════════════════════════════════════════════════════════════════════──────
anytime I want to do something new on my computer, I write a bash script.
if I forgot how to do the thing, I spend time meandering about my
file-directory-system. If I don't find it, that's okay, because all I have to
do is keep looking until I stumble upon it.
kinda makes me wish I had an LLM who managed the operating system and named
files with long-and-descriptive titles while taking in as context the general
eternal prompt stored in ~/.claude.md or wherever
--> /home/ritz/programs/cloud-code/
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧══════════════════════════════════════════════════════════════════════─────┘
--- #11 fediverse/1567 ---
═════════════════════════════════════════════════──────────────────────────────────
I helped make a script that saves the last directory you CD'd to in every
shell / terminal. It helps because when I open a new terminal I'm already
where I was working last, which means I'm less likely to forget what I was
doing.
However, it does make my home directory a bit more messy, as I no longer open
my computer to that place.
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧══════════════════════════════════════════─────────────────────────────────┘
--- #12 fediverse/5663 ---
═══════════════════════════════════════════════════════════════════════────────────
I'm going to write some lua code that doesn't do anything useful and which I
don't share with anyone
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧════════════════════════════════════════════════════════════════───────────┘
--- #13 fediverse/5873 ---
══════════════════════════════════════════════════════════════════════════─────────
"the problem with linux is you have to spend part of the program just...
interacting with the filesystem. like, where is their /usr/bin file? (oh it's
called a directory over there, my bad) weird they put their config over here
(what language is that written in?) uhhhh I don't know much about localization
settings (-- two computers on a botnet --)
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧═══════════════════════════════════════════════════════════════════────────┘
--- #14 fediverse/3907 ---
══════════════════════════════════════════════════════════─────────────────────────
kinda wanna make a linux distro that has all the capabilities of a GUI distro
and isn't so minimal (like screen recording, calculator, screenshot, wifi
manager, etc etc) but with i3 instead of a desktop.
they could literally just be symlinks (shortcuts) to scripts that are in your
/usr/bin or whatever directory
seriously it's not like there's THAT many ways to use ffmpeg, why not just
write a script for them? that's what you're going to do when you use it for
the first time, anyway, so...
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧═══════════════════════════════════════════════════────────────────────────┘
--- #15 fediverse/582 ---
═════════════════════════════════════════════──────────────────────────────────────
@user-431
I made an alias that overwrites cd so I don't have to do this. The important
line is line 27, you could probably accomplish something similar like this:
alias cd="cd ${1} && ls -v --color=auto"
I also set it up so I can change more than one directory up using ... or ....
or .....
also I have a few shortcut scripts, cdir and qcd. cdir creates a quick way to
drop a bookmark wherever I'd like, while qcd can make permanent bookmarks.
Also qcd makes it so whenever I open a new terminal it opens to the last
directory I was in, which is nice if you need a new terminal to do something
in the current folder and you don't want to have to walk alllllllll the way
back.
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧══════════════════════════════════════─────────────────────────────────────┘
--- #16 fediverse/2674 ---
══════════════════════════════════════════════════════─────────────────────────────
┌────────────────────────────────────────────────────────────────────┐
│ CW: factually-untrue,-that-never-happened.-this-is-just-gesturing. │
└────────────────────────────────────────────────────────────────────┘
the kind of friendship where you SSH into each other's systems and leave notes
for one another.
as soon as you find one you message the person who left it like "yoooo only
just found this lol" and they're like oooo yeah did you see the bash script I
wrote in that directory "yeah totally I used it on one of my video files just
now - cool filter!"
ahhhh reminds me of all the times hackers have hacked my permanently insecure
system and left me friendly messages like "hey I'm on your side" or "how's
life, friend? I hope it's going well." or "never forget; you are worth all the
fear" y'know cute things like that
oh. right. because leaving vulnerabilities like that can lead to threat actors
affecting your stuff. how lame.
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧═══════════════════════════════════════════════────────────────────────────┘
--- #17 fediverse/3680 ---
════════════════════════════════════════════════════════───────────────────────────
it's probably a good idea to write pseudocode, then real code, instead of
starting with real code, and bugfixing something incomplete and more difficult
to reason with.
unless you write real code easier than pseudocode. idk do what works for you.
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧═════════════════════════════════════════════════──────────────────────────┘
--- #18 fediverse/3878 ---
══════════════════════════════════════════════════════════─────────────────────────
@user-570
that's not actually my script, here's the real one:#!/bin/bash
alias cd="cd-improved"
function cd-improved(){
if [ "${1}" = "..." ] ; then
builtin cd .. && builtin cd ..
elif [ "${1}" = "...." ] ; then
builtin cd .. && builtin cd .. && builtin cd ..
elif [ "${1}" = "....." ] ; then
builtin cd .. && builtin cd .. && builtin cd ..
&& builtin cd ..
elif [ -d "./${1}" ] ; then
local target_dir="./${1}"
elif [ "${1}" = "cdir" ] ; then
local target_dir="$(tail -n 1 '/home/ritz/scripts/.cdir-target')"
echo ${target_dir}
else
local target_dir="${1}"
fi
if [ ! "${2}" = '--no-ls' ] ; then
builtin cd "${target_dir}" && ls -v --color=auto
else
builtin cd "${target_dir}"
fi
}
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧═══════════════════════════════════════════════════────────────────────────┘
--- #19 fediverse/345 ---
════════════════════════════════════════════───────────────────────────────────────
If you want to write object oriented C, just make one file per class and use
static functions for private methods.
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧═════════════════════════════════════──────────────────────────────────────┘
--- #20 fediverse/1773 ---
═════════════════════════════════════════════════════──────────────────────────────
┌─────────────────────────┐
│ CW: programming-is-easy │
└─────────────────────────┘
Need to install a program from Github? Follow these simple steps:
step 1: make an empty text file
step 2: put this at the top: #!/bin/bash
step 3: put this on the next line: set -euo pipefail
step 4: mkdir -p the directory you want to install it to
step 5: rm -dr the directory you want to install it to
step 6: mkdir -p the directory you want to install it to
step 7: git clone the project
step 8: this is the hard part - go through each of the steps listed in the
readme and configure the installation to the needs of your system. Put them in
the bash script one-by-one.
step 9: save the file, it doesn't need an extension like .txt or .sh,
extensions are for windows noobs
step 10: chmod +x the file and then ./the file!
step 11: fix it when they change their installation instructions...
Need a run script? Easy! Write it as a function below your update script, then
echo the bottom half of the update script into a file named "run" that's
placed in the project directory.
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧══════════════════════════════════════════════─────────────────────────────┘
|