My fav script to unpack anything, found a few years ago somewhere # ex - archive extractor # usage: ex function ex() { if [ -f $1 ] ; then case $1 in *.tar.bz2) tar xjf $1 ;; *.tar.gz) tar xzf $1 ;; *.tar.xz) tar xf $1 ;; *.bz2) bunzip2 $1 ;; *.rar) unrar x $1 ;; *.gz) gunzip $1 ;; *.tar) tar xf $1 ;; *.tbz2) tar xjf $1 ;; *.tgz) tar xzf $1 ;; *.zip) unzip $1 ;; *.Z) uncompress $1;; *.7z) 7z x $1 ;; *) echo "'$1' can…
Scripts I wrote that I use all the time
121–130 of 408 posts
Re: Scripts I wrote that I use all the time
#122My fav script to unpack anything, found a few years ago somewhere # ex - archive extractor # usage: ex function ex() { if [ -f $1 ] ; then case $1 in *.tar.bz2) tar xjf $1 ;; *.tar.gz) tar xzf $1 ;; *.tar.xz) tar xf $1 ;; *.bz2) bunzip2 $1 ;; *.rar) unrar x $1 ;; *.gz) gunzip $1 ;; *.tar) tar xf $1 ;; *.tbz2) tar xjf $1 ;; *.tgz) tar xzf $1 ;; *.zip) unzip $1 ;; *.Z) uncompress $1;; *.7z) 7z x $1 ;; *) echo "'$1' can…
Re: Scripts I wrote that I use all the time
#123> trash a.txt b.png moves `a.txt` and `b.png` to the trash. Supports macOS and Linux. The way you’re doing it trashes files sequentially, meaning you hear the trashing sound once per file and ⌘Z in the Finder will only restore the last one. You can improve that (I did it for years) but consider just using the `trash` commands which ships with macOS. Doesn’t use the Finder, so no sound and no ⌘Z, but it’s fast, offici…
Re: Scripts I wrote that I use all the time
#124Nice! Tangentially related: I built a (MacOS only) tool called clippy to be a much better pbcopy. It was just added to homebrew core. Among other things, it auto-detects when you want files as references so they paste into GUI apps as uploads, not bytes. clippy image.png # then paste into Slack, etc. as upload clippy -r # copy most recent download pasty # copy file in Finder, then paste actual file here https://githu…
Re: Scripts I wrote that I use all the time
#125The flags are for maximum compatibility (e.g. without them, some MP4s don't play in WhatsApp, or Discord on mobile, or whatever.)
ffmp4() {
input_file="$1"
output_file="${input_file%.*}_sd.mp4"
ffmpeg -i "$input_file" -c:v libx264 -crf 33 -profile:v baseline -level 3.0 -pix_fmt yuv420p -movflags faststart "$output_file"
echo "Compressed video saved as: $output_file"
}
ffmp4 foo.webm-> foo_sd.mp4
fftime() {
input_file="$1"
output_file="${input_file%.*}_cut.mp4"
ffmpeg -i "$input_file" -c copy -ss "$2" -to "$3" "$output_file"
echo "Cut video saved as: $output_file"
}
fftime foo.mp4 01:30 01:45-> foo_cut.mp4
Note, fftime copies the audio and video data without re-encoding, which can be a little janky, but often works fine, and can be much (100x) faster on large files. To re-encode just remove "-c copy"
Re: Scripts I wrote that I use all the time
#126Earlier quoted context omitted.
You can apply your dotfiles to servers you SSH into rather easily. I'm not sure what your workflow is like but frameworks like zsh4humans have this built in, and there are tools like sshrc that handle it as well. Just automate the sync on SSH connection. This also applies to containers if you ssh into them.
I'm guessing you haven't worked in Someone Else's environment? The amount of shit you'll get for "applying your dotfiles" on a client machine or a production server is going to be legendary. Same with containers, please don't install random dotfiles inside them. The whole point of a container is to be predictable.
Re: Scripts I wrote that I use all the time
#127It's weird how the circle of life progresses for a developer or whatever. - When I was a fresh engineer I used a pretty vanilla shell environment - When I got a year or two of experience, I wrote tons of scripts and bash aliases and had a 1k+ line .bashrc the same as OP - Now, as a more tenured engineer (15 years of experience), I basically just want a vanilla shell with zero distractions, aliases or scripts and use…
I think it's more likely to say that this comes from a place of laziness than some enlightened peak. (I say this as someone who does the same, and is lazy). When I watch the work of coworkers or friends who have gone these rabbit holes of customization I always learn some interesting new tools to use - lately I've added atuin, fzf, and a few others to my linux install
https://github.com/atuinsh/atuin
Discussed 4 months ago:
Atuin – Magical Shell History https://news.ycombinator.com/item?id=44364186 - June 2025, 71 comments
Re: Scripts I wrote that I use all the time
#128I have mkcd exactly ( I wonder how many of us do, it's so obvious) I have almost the same, but differently named with scratch(day), copy(xc), markdown quote(blockquote), murder, waitfor, tryna, etc. I used to use telegram-send with a custom notification sounnd a lot for notifications from long-running scripts if I walked away from the laptop. I used to have one called timespeak that would speak the time to me every h…
Edit: looks like it’s a zsh thing
Re: Scripts I wrote that I use all the time
#129My fav script to unpack anything, found a few years ago somewhere # ex - archive extractor # usage: ex function ex() { if [ -f $1 ] ; then case $1 in *.tar.bz2) tar xjf $1 ;; *.tar.gz) tar xzf $1 ;; *.tar.xz) tar xf $1 ;; *.bz2) bunzip2 $1 ;; *.rar) unrar x $1 ;; *.gz) gunzip $1 ;; *.tar) tar xf $1 ;; *.tbz2) tar xjf $1 ;; *.tgz) tar xzf $1 ;; *.zip) unzip $1 ;; *.Z) uncompress $1;; *.7z) 7z x $1 ;; *) echo "'$1' can…
So, you created a square wheel, instead of a NASA wheel.