#Shell Script
Explore tagged Tumblr posts
Text
updating my "resvim" script to support changing working directory and i've come across an interesting design choice to make:
the script checks for "-d" flag as $1 and passes $2 to vim remotely
vim --servername MAIN --remote-send ":cd $2<CR>"
however, because the remaining file arguments are relative to the shell's working directory, invoking it from idk ~/Documents as
resvim -d ~/Projects/Foo bar.c baz.c
results in vim changing to ~/Projects/Foo but trying to open ~/Documents/bar.c and ~/Documents/baz.c
so, my options are:
leave as-is (in case you wanna open files from your shell's PWD but change vim's PWD; also makes dealing w/ relative and absolute paths easier)
force file arguments after a '-d' flag to be relative to that directory ONLY
add a new flag that specifies files are relative to the path provided by '-d'; otherwise, leave as-is (potentially simplifies things re: option 1)
oh, i should mention this is fully POSIX-compliant shell despite it being unlikely i'll need it to be portable (plus it depends on dtach and currently i3 soooo) and just as unlikely anyone else would use it d:
#daemon.md#shell script#POSIX shell#linux#progblr#design decisions are the most interesting part tbh#closely followed by dumb simple solutions to complex problems#and then by code golfing xD
3 notes
·
View notes
Text
stop using chatgpt!!!! take a bronze pin and carve your questions onto an ox scapula, then toss it into the fire!!!! use the cracks to divine the gods answer!!!!
58K notes
·
View notes
Text
Open the most recent file for a given folder
So at work we use this gem called letter_opener to handle emails in the local rails environment. When an email is sent in your rails environment, then letter opener stores it in tmp/letter_opener and automatically opens the email in your browser. It's very useful when resetting your password on local, or testing new mailers etc.
Brilliant, you say! Yes, it is. However, since we migrated to Docker in our local environment, the automagical opening in your browser feature no longer works. The email html still generates in the tmp/letter_opener folder but it's a pain in the neck to dig around in there every time you need to check an email. So I set about finding an alternative way to open the emails. I settled on a simple shell script that would find the most recent html file in the tmp/letter_opener folder and open it using the open command:
open $(find /path/to/search -type f -name "rich.html" -exec ls -lt -- {} + | head -n 1)
I have this assigned to a zsh alias called email. Every time I need to check an email I can trigger it and see the last email my rails app sent in my browser.
P.S. I've also been thinking about exploring using a mac folder action to achieve a similar feature to the original functionality. This would trigger whenever a new file appeared in the tmp/letter_opener directory and open it in the browser.
1 note
·
View note
Text
Macbook Battery Stats in Your ZSH Terminal Prompt
As a power user of my Macbook, I’ve found that I often overlook the small battery icon on my menu bar, especially when I’m immersed in a fun project. This minor inconvenience sparked a thought: why not incorporate the battery status directly into my terminal prompt? Thus, I embarked on a fun exploration into ZSH scripting. With a bit of coding magic, I was able to enhance my terminal prompt to…
View On WordPress
#Automation#Battery Monitor#Coding#Command Line#Customization#MacBook#MacOS#Power Management#Productivity#Scripting#Shell Script#Tech Hacks#Terminal#User Experience#zsh
0 notes
Text
How to convert or encode a file into a single line base64 string using Linux command line ?
Recently I came across a use case to store the license associated with a software securely in a vault. The license was a binary file. The only way to store in the secure vault was to convert it as a string. I used the following command to convert the file into a single line base64 string. cat <file-name> | base64 -w 0 The -w 0 option aligns the encoded string into a single line string. If you…
View On WordPress
#base64 encode a file#CentOS#convert a file into a single line base64 string#encode a file into a single line base64 string#linux command line#RHEL#shell script#ubuntu
1 note
·
View note
Text
you shouldn't need to cat the link file. I think… just for i in media-links.txt; ? Not sure of syntax, on my phone in bed RN
For the URL encode issue, try mv "$file" "${count}-${file}"
Always quote your vars, and use the curly braces too if needed
also seems like file=echo $i is useless? It simplifes down to file=$i as far as I can tell (while adding a chance of unquoted spaces and such)? Just use $i later on in the mv, should be the same.
I hope this may help, on the other hand like I said this all out of my brain no testing or even lookup cause on my phone and its a pain, so maybe it is useless and wrong LOL
Also check out the linter "shellcheck", it is fucking rad.
So, wrote a dumb bash thing
$> count=$(wc -l media-links.txt) $> for i in $(cat media-links.txt); do wget $i; file=echo $i | awk -F '/' '{print $NF}'; mv $file $count-$file; count=$((count - 1)); sleep 2 ; echo ================================; done
It mostly works, although that sleep apparently needs to be longer because I was getting of "ERROR 429: Too Many Requests".
The rename doesn't always work because sometimes the URL has a URL encoded character, which gets decoded by wget when the actual file gets saved. e.g.
--2024-07-01 00:11:17-- https://static1.squarespace.com/static/55dca83de4b018ac1524526f/t/622990a6d88dfa624f168cbd/1646891207920/Samuel+Spruce%2C+The+Little+Wooden+Boy+in_+The+Frosty+Wood.mp3 Resolving static1.squarespace.com… 146.75.32.238 Connecting to static1.squarespace.com|146.75.32.238|:443… connected. HTTP request sent, awaiting response… 200 OK Length: 33151680 (32M) [audio/mpeg] Saving to: ‘Samuel+Spruce,+The+Little+Wooden+Boy+in_+The+Frosty+Wood.mp3’ Samuel+Spruce,+The+Little+Wooden+Boy+in_+The+Frosty 100%[=================================================================================================================>] 31.62M 20.2MB/s in 1.6s 2024-07-01 00:11:19 (20.2 MB/s) - ‘Samuel+Spruce,+The+Little+Wooden+Boy+in_+The+Frosty+Wood.mp3’ saved [33151680/33151680] mv: can't rename 'Samuel+Spruce%2C+The+Little+Wooden+Boy+in_+The+Frosty+Wood.mp3': No such file or directory
Anyway, that's a problem for future me.
14 notes
·
View notes
Text
#art#painting#oil on canvas#candle#flowers#compass#hourglass#script#skull#book#sea shell#pipe#still life#vanitas#memento mori#nicolaes van verendael#vanitas still life 1680
228 notes
·
View notes
Text
i think queer identity makes people boring and not the other way around. i come across so many women who are insightful and smart and funny who identify as some flavor of nonbinary or queer and its like once they remember "oh yeah i identify as those things" in the middle of a conversation it comes across as insincere and random and dull to whatever we were previously talking about. like when they're being themselves they're complex individuals, but once they remember they have to push an identify complex on themselves and have to make sure you know they don't feel like a woman 100% of the time or something all their personality suddenly tanks as they try to artificially craft themselves to you.
#i know many of us joke that these people collect identities bc they're boring but like have we considered the opposite is also occuring#that by opting into one of these alphabet soup identities it forces the person to play a role that's so insincere in the social scripts it#requires that they become a boring shell of a person as they follow the scripts?#and once they stop following the scripts they return to being a normal interesting person#radical feminism#radical feminist#radfem
589 notes
·
View notes
Text
saw the clip of landoscar touching hands and IMMEDIATELY hopped onto tumblr.com. i know the girls are losing their minds over this. thank you hilton 🙏🏼
#landoscar#i can’t figure out if this is scripted or not#bc some moments feel so THEM especially oscar’s natural reactions to lando#but also the end was DEFINITELY scripted#are they just better actors than i expected??#maybe c2 were just so bad in the shell ads that it lowered my expectations for everyone else#also#completely random but how do you think lando would’ve fared as a drama/theatre kid?#i can kinda see it in him#i feel like normal high schooler non-racing driver lando would’ve signed up for laughs and ended up becoming unexpectedly invested
91 notes
·
View notes
Text
Wouldn't it make the man page have line numbers on the side?
Not necessarily
So I'd have to add another if case onto my bashrc and those are slow
Learn to use && and ||. && is non-branching then, || is non-branching else. No shell should take a full second to start.
But yes Debian calling it batcat is kinda dumb.
i just spent like an hour to solve linux problem again.. because my man page colors suddenly stopped working! and you can't have uncolorful man pages. 0_0
thankfully i had a second machine (my server) to compare outputs to..
i eventually tracked down the culprit, and it was groff being updated to version 1.23.0! seems totally unrelated to man, doesn't it¿ :)
now i have to figure out if i can solve this better than just downgrading it to 1.22.4
PS: i spent way too much time barking up the less tree, because the config variables are called LESS_TERMCAP_*
edit: you have to set the GROFF_NO_SGR environment variable to 1
50 notes
·
View notes
Text
I am watching all the Link Click endorsed CMs, Part 1 : Link Click X 王老吉 Wang Lao Ji (herbal tea drink)
#Link Click#shi guang dai li ren#时光代理人#Yea I am watching all the Link Click commercials#I think you will find this drink very familiar Yuigadokson!#Studio Lan be straight-up animating full-length CMs like it was left over footage they had sitting around#This is something I don't really see happen with *anime* product endorsed CMs#^ most times they just borrow readily available footage direct from the anime or manga to use#These sponsors really did shell out monies for the full nine yards#Imagine the production cost of an animated short from scratch complete with a full script and voice over!#It dang well could be an omake on its own merit
64 notes
·
View notes
Text
A Bash Script to Read All Command Line Arguments into an Array Using mapfile Command: Simplify Argument Handling
12 notes
·
View notes
Text
Listen carefully. LOVE Rise. Absolutely fantastic rendition of the turtles. But if there's one thing '03 did better, it's the amount of times they use the word shell as a swear. My GOSH if that's not the funniest, punniest, stupidest shit I have ever seen. I laugh every damn TIME.
#I literally have started saying what the shell#I cry laughing every time#where the SHELL are we??#tmnt#tmnt 2003#rise tmnt#rottmnt#the script writers were COOKING with this oh my gosh#Btw if it wasn't obvious#this is meant to be lighthearted#but I'm also so deadass#I need more what the shell shit ty
38 notes
·
View notes
Text
I made a cute little startup notification greeter for my Linux system (but it should work anywhere you have access to a POSIX-compliant shell, the date command, and the notify-send command!) I have it included in my window manager's startup script, so it will run every time I log on.
#!/bin/sh [ "$(date +%H)" -gt "11" ] && GREET="afternoon" || GREET="morning" notify-send "Welcome." "Good $GREET, $USER"
That first line is doing a few things. First, it is getting the current hour (in 24-hour time, so an integer between 0 and 23) with $(date +%H). Then the -gt checks if it is greater than 11 (NOT 12; our hour value starts at 0) . If the hour is greater than 11, it sets the variable GREET to "afternoon". If the hour is NOT greater than 11, it sets GREET to "morning".
The second line is a call to the notify-send command, a simple command-line program to send desktop notifications. We pass 2 arguments: The notification title (or "summary" as it is referred to in the documentation), and the body. Our title is simply "Welcome." In the body, we call 2 variables: the GREET variable we set in the first line, and the USER variable which stores your username.
(my setup: Dunst notification daemon, with the Catppuccin Mocha color scheme)
31 notes
·
View notes
Text
i am loading up the boop gun. some of u beloved mutuals are about to come under fire
2 notes
·
View notes
Text
if the mets lose tonight my soul will be crushed beyond repair and i will have to pretend i’m functioning like normal when i’m not and NO i’m not being dramatic!!!
#especially bc the stupid yankees are already going to the world series#if i have to see the yankees in the series and the mets lose i will be a shell of a person#but at least if the dodger win i can blame it on the mlb script and pretend it doesn’t matter#let’s go mets!
2 notes
·
View notes