I have a bunch of little scripts and aliases I've written over the years, but none are used more than these... alias ..='cd ..' alias ...='cd ../..' alias ....='cd ../../..' alias .....='cd ../../../..' alias ......='cd ../../../../..' alias .......='cd ../../../../../..'
I need this *so* often that I programmed my shell to execute 'cd ..' every time I press KP/ i.e. '/' on the keypad, without having to hit Return. Other single-key bindings I use often are: KP* executes 'ls' KP- executes 'cd -' KP+ executes 'make -j `nproc`'
Scripts I wrote that I use all the time
201–210 of 408 posts
Re: Scripts I wrote that I use all the time
#202Re: Scripts I wrote that I use all the time
#203> 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
#204Re: Scripts I wrote that I use all the time
#205It'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…
Given the nature of current operating systems and applications, do you think the idea of “one tool doing one job well” has been abandoned? If so, do you think a return to this model would help bring some innovation back to software development? Rob Pike: Those days are dead and gone and the eulogy was delivered by Perl.
Re: Scripts I wrote that I use all the time
#206 echo 1 2 3 | each "rm {}"
is the same as rm 1
rm 2
rm 3
while echo 1 2 3 | xargs rm
is the same as rm 1 2 3
I would rather say that 'each' replaces (certain uses of) 'for': for i in 1 2 3; do rm $i; doneRe: Scripts I wrote that I use all the time
#207Please note that 'each' is fundamentally different from 'xargs'. echo 1 2 3 | each "rm {}" is the same as rm 1 rm 2 rm 3 while echo 1 2 3 | xargs rm is the same as rm 1 2 3 I would rather say that 'each' replaces (certain uses of) 'for': for i in 1 2 3; do rm $i; done
-I replace-str
Replace occurrences of replace-str in the initial-arguments
with names read from standard input. Also, unquoted blanks
do not terminate input items; instead the separator is the
newline character. Implies -x and -L 1.Re: Scripts I wrote that I use all the time
#208> ocr my_image.png extracts text from an image and prints it to stdout. It only works on macOS The Mac Shortcut at https://github.com/e-kotov/macos-shortcuts lets you select a particular area of the screen (as with Cmd-Shift-4) and copies the text out of that, allowing you to copy exactly the text you need from anywhere on your screen with one keyboard shortcut. Great for popups with unselectable text, and copying er…
Re: Scripts I wrote that I use all the time
#209Some cool things here but in general I like to learn and use the standard utilities for most of this. Main reason is I hop in and out of a lot of different systems and my personal aliases and scripts are not on most of them. sed, awk, grep, and xargs along with standard utilities get you a long long way.
I value out of the box stuff that works most everywhere. I have a fairly lightweight zsh config I use locally but it’s mostly just stuff like a status like that suits me, better history settings, etc. Stuff I won’t miss if it’s not there.
Re: Scripts I wrote that I use all the time
#210 function unix() {
if [ $# -gt 0 ]; then
echo "Arg: $(date -r "$1")"
fi
echo "Now: $(date) - $(date +%s)"
}
Prints the current date as UNIX timestamp. If you provide a UNIX timestamp as arg, it prints the arg as human readable date.