It's been a while since I haven't read something as useful! There also some very niche stuff that I won't use but found funny
The nato phonetic alphabet one cracked me up. My dude you don't need that, call center employees don't know it, just say S as in Sugar like ur grandma used to.
Scripts I wrote that I use all the time
171–180 of 408 posts
Re: Scripts I wrote that I use all the time
#172Earlier quoted context omitted.
Or more abstractly: post anything to the internet and people will always detail how you’re wrong. Sometimes that can be useful.
That seems to be especially true on HN. Other forums there is some of that as well, but HN it seems nearly every single comment section is like 75% (random number) pointing out faults in the posted article.
I've found that pedantic conversations here seem to actually have a greater potential for me to learn something from them than other forums/social platforms. On other platforms, I see someone providing a pedantic response and I'll just keep moving on, but on HN, I get curious to not only see who wins the nerd fight, but also that I might learn at least one thing along the way. I like that it's had an effect on how I engage with comment sections.
Re: Scripts I wrote that I use all the time
#173I 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…
Doesn’t the built in `take` do exactly what `mkcd` does? Or is `take` a zsh/macos specific thing? Edit: looks like it’s a zsh thing
Re: Scripts I wrote that I use all the time
#174jsonformat -> jq
running -> pgrep
Re: Scripts I wrote that I use all the time
#175Earlier quoted context omitted.
That seems to be especially true on HN. Other forums there is some of that as well, but HN it seems nearly every single comment section is like 75% (random number) pointing out faults in the posted article.
Although I normally loathe pedantic assholes, I've found the ones on HN seem to be more tolerable because they typically know they'll have to back up what they're saying with facts (and ideally citations). I've found that pedantic conversations here seem to actually have a greater potential for me to learn something from them than other forums/social platforms. On other platforms, I see someone providing a pedantic r…
Re: Scripts I wrote that I use all the time
#176> wifi toggle this fella doesn't know what "toggle" means. in this context, it means "turn off if it's currently on, or turn on if it's currently off." this should be named `wifi cycle` instead. "cycle" is a good word for turning something off then on again. naming things is hard, but it's not so hard that you can't use the right word. :)
Re: Scripts I wrote that I use all the time
#177 # If this is an xterm set the title to the directory stack
case "$TERM" in
xterm*|rxvt*)
if [ -x ~/bin/shorten-ds.pl ]; then
PS1="\[\e]0;\$(dirs -v | ~/bin/shorten-ds.pl)\a\]$PS1"
else
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
fi
;;
\*)
;;
esac
The script shorten_ds.pl takes e.g. 0 /var/log/apt
1 ~/Downloads
2 ~
and shortens it to: 0:apt 1:Downloads 2:~
#!/usr/bin/perl -w
use strict;
my @lines;
while () {
chomp;
s%^ (\d+) %$1:%;
s%:.*/([^/]+)$%:$1%;
push @lines, $_
}
print join ' ', @lines;
That coupled with functions that take 'u 2' as shorthand for 'pushd +2' and
'o 2' for 'popd +2' make for easy manipulation of the directory stack: u() {
if [[ $1 =~ ^[0-9]+$ ]]; then
pushd "+$1"
else
pushd "$@"
fi
}
o() {
if [[ $1 =~ ^[0-9]+$ ]]; then
popd "+$1"
else
popd "$@" # lazy way to cause an error
fi
}Re: Scripts I wrote that I use all the time
#178My 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
#179It'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…
man, i couldn't live without alias ..='cd ..' or alias ...='cd ../..' to this day, i still get tripped up when using a shell for the first time without those as they're muscle memory now.