#Shell Script
Explore tagged Tumblr posts
daemonhxckergrrl · 2 years ago
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:
3 notes · View notes
grand-theft-carbohydrates · 4 months ago
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
happyscripter · 1 year ago
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
lokirme · 1 year ago
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…
Tumblr media
View On WordPress
0 notes
amalgjose · 2 years ago
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
1 note · View note
ailurinae · 5 months ago
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
sictransitgloriamvndi · 8 months ago
Text
Tumblr media
228 notes · View notes
femmesandhoney · 2 years ago
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.
589 notes · View notes
papayafiles · 9 months ago
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 🙏🏼
91 notes · View notes
mirqmarq428 · 1 year ago
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
syncopatedid · 1 year ago
Text
Tumblr media Tumblr media Tumblr media Tumblr media Tumblr media Tumblr media Tumblr media Tumblr media Tumblr media Tumblr media Tumblr media Tumblr media Tumblr media Tumblr media Tumblr media
I am watching all the Link Click endorsed CMs, Part 1 : Link Click X 王老吉 Wang Lao Ji (herbal tea drink)
64 notes · View notes
nixcraft · 6 months ago
Text
A Bash Script to Read All Command Line Arguments into an Array Using mapfile Command: Simplify Argument Handling
12 notes · View notes
kaitousassistant143 · 1 year ago
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.
38 notes · View notes
allylikes · 1 year ago
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.
Tumblr media
#!/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
synfy · 15 days ago
Text
i am loading up the boop gun. some of u beloved mutuals are about to come under fire
2 notes · View notes
notsocooljess · 26 days ago
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!!!
2 notes · View notes