Live data from Hacker News

macOS command-line tools you might not know about

saurabhs.org

201–210 of 454 posts

Re: macOS command-line tools you might not know about

#202
post #138

Earlier quoted context omitted.

They come from BSD (and, nitpick, are not called coreutils). These BSD tools lack features mostly only if you're used to GNU coreutils. The expanse of GNU coreutils features is questionable too: some are nice, some you can do without easily and rarely to never miss, and some are downright annoying (yes I'm looking at you, ls with colors+quotes)

Obviously everything is preference, but I prefer things like expanded regex in gnu grep to the underpowered macOS utils

GNU and BSD grep both default to "basic" regular expressions and both have the `-E` switch to use "extended" expressions.

Re: macOS command-line tools you might not know about

#203
post #98

Earlier quoted context omitted.

In what way do you see those alternatives as superior?

They avoid an unnecessary invocation of the cat executable. Instead, they open a file descriptor and pass that. Tiny difference but there you go.

I teach shell scripting. Cat invocations are cheap and help learners understand and keep clear where input is coming from, and where it is going. There are no awards or benefits to reducing the number of lines, commands invoked, or finding the shortest possible way to perform a task in a script. There are plenty of detriments to reading and understanding though when we try to obfuscate this to save 1ms of execution time on a script that is going to execute near instantaneously anyways.

In short, I straight up don't care.

Re: macOS command-line tools you might not know about

#204
post #190
post #172

Earlier quoted context omitted.

It's cool to use pbcopy and pbpaste with your phone! Copy some text on the phone, and you can pbpaste it onto the Mac command line. So cool.

It creeps me out when the clipboard is unexpectedly shared between my phone and computer. And since the feature seems to turn on randomly but not reliably when I want it to, I’d rather it just didn’t exist.

For me it’s one of the top benefits of the Apple ecosystem.

The only drawback is that yes it only works most of the time. And when it doesn’t I get infuriated.

Glitches happen without any change to settings or network on my side - it works now, and 5 min later doesn’t.

Re: macOS command-line tools you might not know about

#205

Shoutout to the `diskutil` command line utility on macOS. I had problems with some slices on a disk today, and was not able to fix it with the graphical Disk Utility that comes with macOS. These slices were remnants from experimenting with running Asahi Linux on the machine in the past. I knew there had to be a way to fix it with diskutility cli program. I found a thread, and the solution for what to do in such situa…

`diskutil` is great but it's a travesty what they did to Disk Utility.app. It never really got any love after the APFS transition and there are things it straight up fails to do the `diskutil` command doesn't. Before they re-designed the interface, it was such a rock-solid tool that even if it failed during some task, would typically tell you why. Now it's a baby LEGO Duplo interface meant for nothing more than reformatting a flash drive.

Re: macOS command-line tools you might not know about

#206
post #93
post #28

Earlier quoted context omitted.

Since you mention both pbcopy and iTerm - I love https://github.com/skaji/remote-pbcopy-iterm2 . I do most of the work on a remove Linux server, treating my MacBook as mostly a dumb terminal, and being able to transparently copy from the remove to my local clipboard is so nice.

The tmux integration in iterm is also very nice for remote work if you haven’t tried it out.

I have tried it, but for whatever reason I just don't like it. I prefer just running tmux in iTerm with no integration.

On the topic, you can also integrate tmux with the native clipboard - I have set copy-pipe to the remote pbcopy, so any selection done in tmux get copied to my local clipboard. I also just found out that tmux also support it natively (https://github.com/tmux/tmux/wiki/Clipboard#the-set-clipboar...).

Re: macOS command-line tools you might not know about

#207
post #189

Earlier quoted context omitted.

Yes, this iterative procedure is often why "useless" cats get put into it. It's a very effective way of processing regular text information. e.g. I need to grab some info from textfile.txt to use as arguments to a function. cat textfile.txt looks like its comma delimited. cat textfile.txt | cut -d, -f 2-5 ah, its the third and fourth column i need cat textfile.txt | cut -d, -f 3-4 | grep '123456' perfect cat textfile…

> cat textfile.txt > looks like its comma delimited. Interesting; why wouldn't you use `head`? Who knows how big textfile.txt is?

`file` will tell you too

Re: macOS command-line tools you might not know about

#208
post #189

Earlier quoted context omitted.

Yes, this iterative procedure is often why "useless" cats get put into it. It's a very effective way of processing regular text information. e.g. I need to grab some info from textfile.txt to use as arguments to a function. cat textfile.txt looks like its comma delimited. cat textfile.txt | cut -d, -f 2-5 ah, its the third and fourth column i need cat textfile.txt | cut -d, -f 3-4 | grep '123456' perfect cat textfile…

> cat textfile.txt > looks like its comma delimited. Interesting; why wouldn't you use `head`? Who knows how big textfile.txt is?

[deleted]

Re: macOS command-line tools you might not know about

#209
post #190
post #172

Earlier quoted context omitted.

It's cool to use pbcopy and pbpaste with your phone! Copy some text on the phone, and you can pbpaste it onto the Mac command line. So cool.

It creeps me out when the clipboard is unexpectedly shared between my phone and computer. And since the feature seems to turn on randomly but not reliably when I want it to, I’d rather it just didn’t exist.

I have a clipboard manager application called "Paste" (creative i know). Its an awesome app for a million reasons. But one thing I like is that it allows me to see and hear when my iphone copy worked.

So I have it enabled so there is a sound when something goes into the clipboard. Even on my mac, I have come to rely on that audio feedback. But it has the added benefit that when I am using my phone in front of my computer and I copy something on my phone, I immediate (and it is impressively fast... maybe a 200ms delay), I hear the chime that something was added to my clipboard on my mac. So it gives you that good feedback that a copy "worked".

You can also shift+cmd+V to see the clipboard history, which is another complimentary tool with universal clipboard because if a paste isn't working as expected you can see if the universal copy never "took" (as you mentioned it is semi-unreliable), or if it just got overridden. You can then use the navigator to paste the older item.

Re: macOS command-line tools you might not know about

#210
post #195
post #190

Earlier quoted context omitted.

It creeps me out when the clipboard is unexpectedly shared between my phone and computer. And since the feature seems to turn on randomly but not reliably when I want it to, I’d rather it just didn’t exist.

Make sure both your phone and computer have Wi-Fi and Bluetooth turned on.

I'm curious why the Bluetooth is required?

Requiring WiFi makes (so the phone/computer is on a network and can communicate with the other devices), but what's the benefit of Bluetooth? Does it only work when the phone and computer are near each other?

Post reply on HN