Live data from Hacker News

macOS command-line tools you might not know about

saurabhs.org

361–370 of 454 posts

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

#361
post #287

A lot of macOS behavior can be toggled by modifying the system component defaults. For example, turn off autohiding of the Dock from commandline: defaults write com.apple.dock "autohide" -bool "false" && killall Dock Include the date in screenshots you take: defaults write com.apple.screencapture "include-date" -bool "true" Here is handy website which documents many of the defaults and their purpose: https://macos-de…

https://github.com/zcutlip/prefsniff can be handy for figuring this stuff out, you start it up, change a setting, and it reports the plist differences to you

Pretty cool tool it looks like. Gonna try using this. Also has good resources in the README.

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

#362

Earlier quoted context omitted.

Agreed. Some of the flags are missing as well. Not sure it's updated often, but still not a bad starting point. If only Apple would publish something directly. They do a pretty good job with the Apple Platform Deployment guide ( https://support.apple.com/guide/deployment ). And the Security guide ( https://support.apple.com/guide/security ).

I maintain updated lists here: https://manp.gs/mac/1/ https://manp.gs/mac/8/

That's awesome. Bookmarked for later!

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

#363
post #357

`open` is one I use all the time. I love that simple command. alias tab='open . -a iterm' alias phpstorm='open -a "PhpStorm"' alias smerge='open -a "Sublime Merge"' etc. I use those more than I do the Open/Recents dialogs in the respective apps.

> alias tab='open . -a iterm' But if you just open a new tab, you'll be in the same $CWD in the new tab? Am I missing some trick here?

In your iterm profile settings, you can configure new tabs to go to either $HOME, $CWD, or a fixed specific directory. I've configured new windows and tabs to $HOME, but new split panes $CWD.

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

#364
post #213

Earlier quoted context omitted.

Don't forget to pipe head into 'cat -v'... that text file could contain _anything_!

I really recommend folks use "less" over cat, especially keyboard oriented folks. Different terminal emulators don't always have the scroll behavior I want, not do they always allow me to search the file I'm looking at. "less" does all those things, in nearly every environment no matter the terminal emulator, and has other wonderful options to boot (chop long lines so they don't wrap can be nice for logs, line number…

I hate that when I use `less`, then quit, the output goes away.

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

#365
post #290
post #8

`pbcopy` and `pbpaste` are one of my most-loved in the list. Dealing with some minified json, switching to iTerm, doing `pbpaste | json_pp | pbcopy` and having a clean output is _so_ nice.

I have a script always running that polls for youtube URLs using pbpaste and runs yt-dl then just highlight any youtube link and COPY later when I have time, I can use quicklook to browse directory of youtube videos.

That’s a great hack thanks for the tip.

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

#366

I just tried the following: I copied all of my ~/.bash_history into GPT and asked it for some commands that would save me time. It didn't quite work to identify "bad patterns" as I had hoped, but it did suggest the following: 1. bat : A `cat` clone with syntax highlighting and Git integration. 2. htop : Interactive process viewer, a better alternative to `top`. 3. fzf : Command-line fuzzy finder to quickly search fil…

>I copied all of my ~/.bash_history into GPT

I wouldn't do that. I treat ChatGPT as public.

But it's a good list nevertheless

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

#367
post #290
post #8

`pbcopy` and `pbpaste` are one of my most-loved in the list. Dealing with some minified json, switching to iTerm, doing `pbpaste | json_pp | pbcopy` and having a clean output is _so_ nice.

I have a script always running that polls for youtube URLs using pbpaste and runs yt-dl then just highlight any youtube link and COPY later when I have time, I can use quicklook to browse directory of youtube videos.

FYI: yt-dlp is more up to date and faster, AFIK: https://github.com/yt-dlp/yt-dlp

I download and save it as 'ytdl' for convenience, but I use it all the time on twitter too.

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

#368

Is there a place Apple documents these things? Do people find these things with something like “ls /usr/bin” and wondering “what is this?” or does Apple have an administrator’s guide somewhere? Or has someone written a good book with this stuff?

I'd love some official Apple documentation. In lieu of that, you can search man pages with `man -f`, `whatis`, or `apropos`. I also keep the following aliases in my ~/.zshrc:

  alias list-functions='functions -x4'
  alias list-function-names='functions +'
  alias list-aliases='alias'
  alias list-alias-names='alias +'
  alias list-commands='print -raC2 ${(kv)commands} | sort'
  alias list-command-names='print -roC1 ${(k)commands}'
  alias list-builtins='print -raC2 ${(kv)builtins} | sort'
  alias list-builtin-names='print -roC1 ${(k)builtins}'
  alias list-everything='whence -cm "[^_]*"'
  alias list-everything-names='whence -wm "[^_]*"'
Edit: another commenter posted what looks to be comprehensive docs/lists here: https://news.ycombinator.com/item?id=36492487

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

#370
post #214
post #98

Earlier quoted context omitted.

In what way do you see those alternatives as superior?

If the command is meant to stream through something really fast by using a large buffer size, then prepending a cat(1) will limit the incoming buffer size to ~4k.

Interesting.

Maybe use dd with one of its blocksize options, then?

Not at a terminal, can't check.

Post reply on HN