27 ms·
macOS command-line tools you might not know about
- tobiasbischoff 3y agoSuper cool.
- gregoriol 3y ago`tmutil` could be added to this list, it's a management cli for Time Machine
- hoherd 3y agoI don't even use Time Machine for my off-machine backups, but I use tmutil to create local snapshots so I can easily back out of changes by using the Time Machine GUI to restore files from the snapshot.
- Etheryte 3y agoNeat, I was not aware of `networkQuality`. A good replacement for opening up Speedtest or whatnot when you just want to figure out if the network is slow or something else is up.
- gargs 3y agoIt seems to grossly underestimate my upload bandwidth!
- audessuscest 3y agosame
- samstave 3y agoWhat are you, a station wagon full of thumb drives?
- varenc 3y agoIt tests your bandwidth while fully saturating your upload AND your download. If maxing out your upload has a huge impact on your download (like, a 70% drop), then that’s probably a sign you could tweak your network for better flow control. That’s sort of the idea of `networkQuality`. It’s a new idea for how to measure that’s different from the standard speed test. Through if you run it with the `-s` flag it’ll test them sequentially.
- gargs 3y agoIn my case, it appears that maximizing my download has a huge impact on my upload as well, which makes sense from a TCP/IP point of view. In this case, do you mean the ISP's flow control?
- varenc 3y agoI'm sure others know waaay more about this, but I think it's a thing you can improve locally. Though usually I think of it as the other way around, where maxing out upload severely impacts download. My understanding is that this causes bufferbloat[0], making packets queue up for a long time on your gateway, ultimately limiting you to way less bandwidth then you should be able to get. My one experience with this is on Ubiquiti hardware where there's a feature called "Smart Queues" you can enable. Really it's FQ_CODEL[1] under the hood. If you tell it your real maximum up/down bandwidth, minus ~5%, it'll enforce those limits in a way that prevents buffer bloat and lets you use nearly your full download bandwidth even when your upload bandwidth is maxed out. On Ubiquiti gear this has a CPU impact since it has move some traffic handling from dedicated hardware to the CPU. But it was a huge night and day difference for me. After enabling this, having a couple people on Zoom calls (highish upload) no longer tanked everyone else's download speed. Also I think this stuff matters more when you have a large multi-user network. For normal home life, definitely not worth it. (In my case it was wifi for ~20 people). [0] https://en.wikipedia.org/wiki/Bufferbloat https://en.wikipedia.org/wiki/Bufferbloat [1] https://en.wikipedia.org/wiki/CoDel https://en.wikipedia.org/wiki/CoDel
- zgluck 3y agoI can't find any (official) documentation on how it measures the speed. Against which target? Edit: Found https://www.macinstruct.com/tutorials/how-to-check-your-macs-network-quality/ https://www.macinstruct.com/tutorials/how-to-check-your-macs... which says: "The networkquality tool uses Apple’s CDN (https://mensura.cdn-apple.com/api/v1/gm/config https://mensura.cdn-apple.com/api/v1/gm/config) as a target" The contents of this file (for me): { "version": 1, "test_endpoint": "sesto4-edge-bx-021.aaplimg.com", "urls": { "small_https_download_url": "https://mensura.cdn-apple.com/api/v1/gm/small", "large_https_download_url": "https://mensura.cdn-apple.com/api/v1/gm/large", "https_upload_url": "https://mensura.cdn-apple.com/api/v1/gm/slurp", "small_download_url": "https://mensura.cdn-apple.com/api/v1/gm/small", "large_download_url": "https://mensura.cdn-apple.com/api/v1/gm/large", "upload_url": "https://mensura.cdn-apple.com/api/v1/gm/slurp" } }
- Etheryte 3y agoI find solace in the fact that even at large companies, there's still enough whimsy to name your upload endpoint slurp.
- varenc 3y agoIt’s a new proposed standard that’s gaining support. People are building alternative party implementations for it: https://github.com/network-quality/goresponsiveness https://github.com/network-quality/goresponsiveness Try running it with `-s` to see if you get speed tests that resemble what you expect. The idea is that maxing out both links at once is a better measure of network quality than sequence speed tests. Also it’s new RTT metric is key.
- wlonkly 3y agoThere is also a CLI client for speedtest.net[1] and fast.com[2]! Not included with MacOS, of course, but nice to have around. [1] https://www.speedtest.net/apps/cli https://www.speedtest.net/apps/cli [2] https://github.com/sindresorhus/fast-cli https://github.com/sindresorhus/fast-cli
- iNic 3y ago`mdfind` and `networkQuality` seem very useful!
- hk1337 3y agoI was aware of about half of these but textutil, networkUtility, and sips I didn’t not and look really interesting
- oneeyedpigeon 3y agoYeah, sips has a lot of potential. The article doesn't mention it, but it can crop as well which could be a real game-changer!
- jfb 3y agoWe heavily used `sips` when I was at Apple, because it was quicker than writing code against QuickTime or the other rendering subsystems.
- boffinAudio 3y agoWut? No fs_usage? Easily one of the most useful of them all .. https://www.manpagez.com/man/1/fs_usage/ https://www.manpagez.com/man/1/fs_usage/ I can't count the number of times a bit of fs_usage foo has helped me dig out of a seriously messy pile of network, file and page fault issues ..
- photonerd 3y agoUseful, but definitely more niche & less generally applicable than the others.
- rockbruno 3y agoXcode uses `mdfind` to provide symbols in crash reports and for Instruments, and is the reason why it seems to have a life of its own and work only when it wants to. Spotlight indexing is extremely flaky for reasons I'm not aware of.
- klausa 3y ago`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.
- eddieroger 3y agoI don't remember when I learned about these, but they've been game changers, and everyone I've shared them with feels the same way. I use your use case often as well, though through `jq` because I'm more familiar with it, and sometimes wish to do transforms.
- nerdponx 3y agoYou can use `python -m json.tool` for just JSON formatting, which is convenient now that Python is available by default in most Linux distros. Jq is really excellent though.
- kps 3y agoOn Linux I have these wrap xsel or xclip, and likewise open to xdg-open. Now, for your Mac example — if that's a specific pipeline you often use, you can write a Service menu entry to do it in place, without switching to a terminal.
- andelink 3y ago+1 to the service menu actions. They are so handy, but often forgotten/overlooked. I think maybe a discoverability issue.
- pmarreck 3y agoI have linux/macos-agnostic bash functions in my dotfiles that unify this to “clip” and “paste” (since “copy” is too close semantically to “cp”)
- kps 3y agopaste(1) is a POSIX standard utility, though (going back to System III), pairing with cut(1). https://pubs.opengroup.org/onlinepubs/9699919799/utilities/paste.html https://pubs.opengroup.org/onlinepubs/9699919799/utilities/p...
- gemstones 3y agoqlmanage is super useful for converting SVG to PNG easily, too! I use it like this: qlmanage -t -s 1000x1000 -o ~/Pictures/foo.png ~/Pictures/foo.svg To turn an square SVG into a PNG without installing anything extra or using an online image tool
- juujian 3y agoIs ```textutil -convert``` using pandoc under the hood?
- kainjow 3y agoIIRC it’s using the Cocoa class NSAttributedStrimg. These conversions have been in the OS for a long time.
- secretsatan 3y agoI thought pandoc used to be installed on MacOS, I def remember using it for something useful a couple of years ago but I check now and it's not there.
- Xen9 3y agoIt's rare to see a "you might not know about" instead of "you never thought about" etc.
- bovermyer 3y agoI just freaked out my cat using `say`. I'm going to enjoy this too much.
- tmearnest 3y agoI used to work at a 24 hr end user tech support call center. They didn’t use Macs, but we had a machine for the techs to use to understand what the customer is looking at. I wrote a script to sleep until late at night then start saying weird/creepy stuff to mess with the overnight crew.
- bendecoste 3y agoCombined with the `yes` command is very good fun ;)
- ubermonkey 3y agoYEARS ago, when my nephew was young, he was playing with my mother's Macbook Air at Thanksgiving. I administer that machine for her (to the extent that such a thing is needed), and so I knew (a) her login and (b) that SSH was open. Me combining remote access with "say" made for a very memorable morning for that kid.
- gen_greyface 3y agotry it out with different voices, for starters try say "process failure" -v trinoids you can find all the available voices with say -v '?' or from Accessibility>Spoken-Content>System-voice>Manage-voices
- mesarvagya 3y agoI liked the option of using `-v organ`
- memco 3y agoA nice feature I discovered recently is -a: you can give it a specific audio device, which falls back to the default if not present. I use it to report when builds finish through my monitor speakers in case I'm not wearing headphones. If I'm on the go and don't have the monitor connected it plays through the speakers.
- nanovision 3y agoNot a big fan of command lines. but my most used shortkey is ALT+M with Maccy installed.
- mattl 3y agoWhat does that do?
- nanovision 3y agoMaccy ( https://maccy.app/ https://maccy.app/ ) is a clipboard manager for Mac and by Clicking ALT+M , it shows all the recent copied texts in a popup.
- mattl 3y agoIs that Option-M?
- nanovision 3y agoI use external logitech keyboard, where it's Alt+M but yes, it's actually Command+M on Macbook
- mattl 3y agoAha! They make Logitech keyboards with Macintosh keys now btw.
- ExoticPearTree 3y agopbcopy/pbpaste are a lifesaver when doing stuff on the command line that has a lot of output and piping is not something you can do. networkQuality is something I really wish I knew about sooner.
- hereonout2 3y agoAlso for things like sharing public ssh keys. Instead of "can you send me your public key" and getting something with random line breaks depending on the users text editor I just have to ask them to "cat ~/.ssh/id_rsa.pub | pbcopy". I also alias pbcopy / pbpaste on Linux too, so useful!
- superq 3y agoThe random linebreaks are ok - SSH can handle them. (that's how Userify does it I think, too. it replicates whatever the user provides.. no judgment :)
- hereonout2 3y agoAh, it's more for ~/.ssh/authorized_keys which is one key per line.
- superq 3y agoright (authorized_keys ignores blank lines and comments)
- jcotton42 3y agoFwiw, `clip` on Windows does the same as `pbcopy` (there's no analog to pbpaste built in though)
- lapcat 3y agoManage the Launch Services database: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister Manage file extended attributes (such as quarantine): xattr Execute a script (AppleScript or JavaScript): osascript -e <statement>
- spookthesunset 3y agoIt’s weird how macs don’t come with a GUI for managing system services. Windows does.. that being said the number of times I’ve had to mess with system services on mac can probably be counted with a few fingers…
- cyberge99 3y agoYou can also prepend #!/usr/bin/osascript to a script and then make it executable with chmod oag+x. You can then invoke it normally in bash: ./filename.sh (or whatever)
- callumprentice 3y agoYears ago, I wrote a script to find something in a big blob of data and to alert me when it was done, I added a “say <some glib Rambo or Schwarzenegger>” type phrase upon completion. I forgot about it and went to bed and was jolted awake hours later by what was clearly an “intruder” speaking to his accomplice, in my home office. Quite the relief when I realized what happened.
- no-dr-onboard 3y agoThat's hilarious! Similar vein: there is a Metasploit module to induce the say command on post-exploited mac machines. I haven't seen it used in practice, but I eagerly watch for the eventual twitter thread that reads: "So, I used the msf module that invokes `say` on a client's laptop"
- joshstrange 3y agoI use Pushover for a few alerts so years ago I wrote a little bash script called `push` that you pass a title and optionally a body. Was very nice to to `./longRunningCommand && push "Task Done" "Here is a body"`. I'd sometimes combine this with my `beep` script that just makes a noise for when I know I'll still be at my computer but want to know when something finishes.
- desro 3y agoWhat's the beep script like? Do you use the terminal bell or does it synthesize a tone?
- joshstrange 3y agoHere is my beep script, it's almost embarrassingly basic. You can pick a different sound, I wanted one that wasn't too offensive/harsh and I've used this for 3-4+ years. #!/bin/bash afplay -v 3 /System/Library/Sounds/Glass.aiff
- jeremy_wiebe 3y agoI often have multiple terminal tabs open. Sometimes I’ll run a command that ends up taking a while and switch away and forget about it. So I added a fish command completion script that plays a beep with afplay if the task took longer than 5 seconds. It helps me get back on task for those “just long enough” tasks that I run.
- donatj 3y agoWhen mentioning `open` they should have noted that `open <file>` will open the given file with its associated app. It’s indispensable.
- lattalayta 3y agoI also find myself using open -n -a <application> to open a new separate instance of an application if I want to copy settings from one file to another or work on two files with separate instances of a program
- computerfriend 3y agoEspecially open . if you need to drag a file somewhere. One thing that kind of breaks my muscle memory here is the opposite, something like firefox file.html doesn't work and you have to fiddle with the arguments to get open to launch a non-default application.
- alanpearce 3y agoIf you set alias firefox="open -a Firefox" This will work
- zora_goron 3y agoI use `open .` to open up a Finder window of the directory I'm currently in using Terminal so frequently that I've set up an alias for it -- alias op='open .'
- ojosilva 3y agoIt took me a while but I finally got open to open folders in a new Finder tab instead of opening a new window each time. function opent () { what=${1:-`pwd`} what=$(cd "$what"; pwd) osascript -e "tell application \"Finder\" activate set t to target of Finder window 1 set toolbar visible of window 1 to true end tell tell application \"System Events\" keystroke \"t\" using command down end tell tell application \"Finder\" set target of Finder window 1 to POSIX file \"$what\" end tell" > /dev/null } ## opens current dir $ opent . ## same $ opent
- karmakaze 3y agoAnother good one is 'hidutil' which can remap any keys without additional software. It's handy for things like remapping CapsLock to anything, etc. For actual full keyboard layouts though I'd use Ukelele[0]. [0] https://software.sil.org/ukelele https://software.sil.org/ukelele
- ris58h 3y agoThere is a helper tool for hidutil https://hidutil-generator.netlify.app/ https://hidutil-generator.netlify.app/ > It's handy for things like remapping CapsLock to anything It's a built-in MacOS feature that you can find in the keyboard settings.
- maxfurman 3y agoI remember Caffeine used to be a third-party program that would prevent your Mac from sleeping, same behavior as the `caffeinate` here. Were they acquired and incorporated into the OS?
- LanceH 3y agoAnyone know of a Ubuntu on WSL equivalent?
- alexdbird 3y agoI believe that Caffeine was a fairly simple GUI wrapper for the existing caffeinate command
- emodendroket 3y ago
- apozem 3y agoI love pbcopy and miss it every time I ssh into my Raspberry Pi. Should be included in every shell environment as standard.
- pqb 3y agoIsn't there `xsel` or `xclip` installed instead [0]? These two commands are commonly used on the Linux boxes and they support pipes too. For example, the xclip is used by the original password-store implementation [1]. On [2] you might find the aliases to pbutil for X11-based Linuxes. [0]: If not, why not run apt-get command to install one of them, like xclip? [1]: https://git.zx2c4.com/password-store/tree/src/password-store.sh#n167 https://git.zx2c4.com/password-store/tree/src/password-store... [2]: https://ostechnix.com/how-to-use-pbcopy-and-pbpaste-commands-on-linux/ https://ostechnix.com/how-to-use-pbcopy-and-pbpaste-commands...
- atarv 3y agoIf you need a more featureful alternative to textutils, look for pandoc https://github.com/jgm/pandoc https://github.com/jgm/pandoc
- dredmorbius 3y agoA strong second to this, it was going to be my own comment ;-)
- BruceEel 3y agoNice list. Also, hidutil (https://developer.apple.com/library/archive/technotes/tn2450/_index.html https://developer.apple.com/library/archive/technotes/tn2450...). Example: hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000049,"HIDKeyboardModifierMappingDst":0x700000065}]}' For my PC keyboard, remaps "Ins" (normally useless under macOS) to something ("PC Execute") I can trap and remap with Keyboard Maestro.
- maratc 3y agohidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000064,"HIDKeyboardModifierMappingDst":0x700000035}]}' Remaps top left key on Euro-style keyboards from useless "paragraph" to useful "backtick".
- kevans91 3y agoYes, this is great... I was given a Macbook with a Norweigan keyboard for testing a port of FreeBSD on it, and I quickly discovered that the keyboard layout remapping stuff available via the UI won't remap at least this one key to what I'd find on my US keyboard.
- hoherd 3y agonot to be confused with hdiutil: hdiutil detach /Volumes/some-usb-drive hdiutil makehybrid -joliet -o foo.iso ./srcfolder/
- frankjr 3y agoThere's a nice generator for these mappings https://hidutil-generator.netlify.app/ https://hidutil-generator.netlify.app/
- xiaomai 3y agoOh wow, this is amazing. I had been unable to _swap_ esc and caps lock on the mac until now.
- whalesalad 3y ago`pbcopy | jq | pbpaste` is a very frequent command that I run to quickly format json in the clipboard. I use pbcopy and pbpaste probably all day long and always miss it in Linux environments.
- Version467 3y agoGreat list. Didn't know about pbcopy/pbpaste, very useful. I use open regularly. Often to open a directory in finder and preview a file. Looks like I can just use qlmanage from now on. Not sure I'd use screencapture manually, but I'm sure there are some automations that could benefit from this.
- gpspake 3y agoI suspect, like me, a lot of people have learned about pbcopy/pbpaste from the Github docs for adding a new SSH key to your account https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account#adding-a-new-ssh-key-to-your-account https://docs.github.com/en/authentication/connecting-to-gith...
- birdyrooster 3y agoI never knew sips was a thing, cool!
- detourdog 3y agoMost people would rather criticize than actually look for goodness.
- brazzledazzle 3y agoProbably want to check your policies if using a business-owned mac. Caffeinate probably violates your security policies if it’s a decent sized company.
- pantulis 3y agoWhy?
- computerfriend 3y agoYou can lock the screen while caffeinated though.
- brazzledazzle 3y agoAutomatic screensaver enable after a period of inactivity is considered a fail safe control.
- wpm 3y ago`caffeinate` can set assertions, the same assertions that Zoom or PowerPoint or Keynote do to stop the screen going to sleep during a meeting or presentation, the same assertions that the browsers can set during streaming video, so you absolutely can bypass whatever your admins set using `caffeinate -dmisu` which sets every assertion available.
- semanticist 3y ago/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport I set an alias in my shell so this is just 'airport', lets you interact with the wifi settings - I particularly like 'airport -s' for doing a scan of the local wifi networks, since it shows signal strength and channel information right there, which is helpful when troubleshooting.
- lloeki 3y agoIt also separates 2.4GHz and 5.0GHz bands and shows security details (which matters sometimes e.g band steering or automatic same-SSID signal-strength-based AP selection doesn't work)
- prvc 3y agoWhat it really needs is a way to prevent sleeping when the lid is closed (only) during a system update.
- pseufaux 3y agoNot a bad list of basic macOS specific cli tools. For a more in depth list, I usually reference https://ss64.com/osx/ https://ss64.com/osx/.
- latexr 3y agoA tad outdated. At a glance I see it’s missing `networkQuality` (introduced in Monterey) and `realpath` (added in Ventura).
- pseufaux 3y agoAgreed. 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 https://support.apple.com/guide/deployment). And the Security guide (https://support.apple.com/guide/security https://support.apple.com/guide/security).
- thefilmore 3y agoI maintain updated lists here: https://manp.gs/mac/1/ https://manp.gs/mac/1/ https://manp.gs/mac/8/ https://manp.gs/mac/8/
- pseufaux 3y agoThat's awesome. Bookmarked for later!
- drewmol 3y agoYes it is, but the forum is current and the creator replies very actively. I’ll ask if he plans update.
- reaperducer 3y agoOne I use a lot: mdls. It's ls for metadata. Very helpful for getting quick and scripted access to the date/time when and the latitude/longitude where a photograph was taken. Also, the say command is a lot more versatile than it seems. Combined with the ability to save the speech to an audio file, my wife uses it as the disc jockey for her little hobby AM radio station. It introduces the song and does little station IDs and such. You can customize it with dozens of dozens of voices, some in very high quality. When a song from her Japanese playlists comes on, it switches to one of the Japanese voices. I don't speak Japanese, so I don't know if it actually translates the DJ words into Japanese, but it sounds pretty close to my untrained ears.
- pantulis 3y agopowermetrics gives a lot of energy usage info per CPU core and apps.
- coding123 3y agoCaffienate will save my ass going forward. I don't know how many times I end up being the person that runs some batch job on my system...
- cpach 3y agoHere’s a nice GUI wrapper: https://apps.apple.com/us/app/amphetamine/id937984704 https://apps.apple.com/us/app/amphetamine/id937984704 (the name might be off-putting to some though)
- wkat4242 3y agoNot a command-line tool but the network link conditioner is also really great. Never seen such a tool on another OS You can simulate a really bad network. Latency, bandwidth, packet loss etc. Great for testing but also if people insist on cameras being on. Just screw up the connection so bad that everyone gets annoyed with your blocky image and robot voice and suggest you turn off video and then you make it 'magically' ok - lol
- elpakal 3y agoYou can do similar magic with Charles Proxy fyi
- obituary_latte 3y agoNever had heard of this before. Some other cool tools in the "additional tools for X-Code" package which I had also never heard of. https://developer.apple.com/download/all/ https://developer.apple.com/download/all/ Thanks for sharing.
- llimllib 3y agoI've used AU Lab to pipe my microphone input through my headphones, which is apparently how professionals like to record audio (a "monitor" so you can hear how you sound), but I couldn't get used to it
- desro 3y agoHow was the latency when you last tried it? Most outboard audio interfaces (even inexpensive ones like the Focusrite Scarletts with ≤ 2 inputs) have a "direct monitor" feature that is as close to zero-latency as you can reasonably get.
- llimllib 3y agoI don’t remember, or have context for how it feels when it’s instant, so I’m a bad tester. Maybe that’s why I didn’t like it, a tiny bit of latency seems like a killer in that scenario
- mechanicker 3y agoUse ‘ditto’ for copying directories. It is fast! https://osxdaily.com/2014/06/11/use-ditto-copy-files-directories-mac-command-line/ https://osxdaily.com/2014/06/11/use-ditto-copy-files-directo...
- cpach 3y agoDitto can also be useful for backup and restore since, AFAICT, it preserves file meta data. (Unlike rsync for example.)
- desro 3y ago`ditto` will also preserve resource forks, which is occasionally necessary for not breaking apps or installer pkgs. I've had to use it when doing a semi-automated deployment of some zipped-up software to a hundred or so Macs via bash over ARD. `ditto -xkv`
- api 3y agoHere are my favorites: alias sleepoff="sudo pmset -a disablesleep 1" alias sleepon="sudo pmset -a disablesleep 0" This fully disables sleep, period. Just make sure you don't leave it unplugged too long, but on Apple Silicon it lasts for quite a long time.
- kec 3y agothis is just a worse version of caffeinate which is more likely to leave you with a dead battery.
- reacharavindh 3y agoIs there any easy shortcut to resizing an image by percentage or fitting to a specific size? Many a times, a website says "file needs to be no bigger than 2 MB", and I need to scramble with Preview app to resize teh app until it falls below that limit. A cli tool for that action would be very handy.
- itake 3y agoI typically use https://www.digitalocean.com/community/tutorials/workflow-resizing-images-with-imagemagick https://www.digitalocean.com/community/tutorials/workflow-re... You can even do bulk cmds with cli on images: for x in ls *.webp; do ffmpeg -i $x ${x%.webp}.png; done reformats images from webp to png in a directory. magick mogrify -monitor -format jpg *.png -compress 70 reformats and compresses pngs to be jpg in a directory
- frankjr 3y agoYou can use ImageMagick's `convert`. convert original.jpg -define jpeg:extent=2MB output.jpg The result will be around 2MB in size (in both directions).
- hgurmen 3y agoIt was nice to find out that macOS has a tool similar to Valgrind called `leaks` that helps you find memory leaks!
- elpakal 3y ago`xed .` Is probably my most underrated macOS command. It will open Xcode using either your project or workspace file.
- jakehilborn 3y agoSelf-plug of displayplacer[0] for changing screen resolutions/rotations/etc via the command line. [0] https://github.com/jakehilborn/displayplacer https://github.com/jakehilborn/displayplacer
- janandonly 3y agoDoes this tool also allow me to change my iPad screen on Sidecar from landscape/horizontal into vertical?
- jakehilborn 3y agoIt's not something that I've tried. There was a user report at the bottom of this GitHub issue that states sidecar rotation does not work. https://github.com/jakehilborn/displayplacer/issues/17 https://github.com/jakehilborn/displayplacer/issues/17
- greenshackle2 3y agoI was hoping this would let me set 125% scaling on my 3440x1440 display but no, I guess it's a hard OS limitation. It's my biggest gripe with MacOS. (There's BetterDisplay - formerly BetterDummy - but it introduces noticeable input lag for me.)
- joshstrange 3y agoThis tool is invaluable, I love it so much. I have 2 workspaces and I love just running the command (via Alfred) when I plug into my dock at either place that fixes all my monitors. I could script it so that as soon as my computer recognizes a monitor UUID it fires off the correct displayplacer command but I don't switch often enough to care (the 2 desks are 3.5+ hours apart). When I was commuting daily displayplacer was even more indispensable but even for just unplugging my mac and using the internal screen vs my monitors I get a ton of value out of this tool.
- shortrounddev2 3y agoWhile you're at it, `brew install coreutils`. The coreutils that ship with macOS lack a lot of features available on Linux. If you use bash, I recommend upgrading it, too, since Apple ships a 16 year old build (iirc due to legal issues associated with GPLv3) `brew install bash`
- Finnucane 3y agoThey're shipping zsh now.
- jonnycomputer 3y agoI've found the transition to zsh surprisingly painless. But then, I do most of my command line scripting on linux and not my own machine. But still.
- latexr 3y agomacOS has shipped Zsh for a long time. The difference is that now (since Catalina), it’s the default shell.
- shortrounddev2 3y agoThat's why I said "if you use bash"
- lloeki 3y agoThey 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)
- shortrounddev2 3y agoObviously everything is preference, but I prefer things like expanded regex in gnu grep to the underpowered macOS utils
- nomilk 3y agoSurprised pngpaste isn't mentioned (in the article nor the comments). If you take a screen shot (command + shift + 4) or partial screen shot (command + shift + control + 4) you can save it directly to an image file with: pngpaste filename.png
- pier25 3y agoBoth commands you listed take a partial screenshot. The first one saves it to the desktop and the second one (with control) to the clipboard.
- nomilk 3y agoOops, you're right. I meant command + shift + control + 3 (full screen to clipboard) and command + shift + control + 4 (partial screen to clipboard).
- agos 3y agocommand shift 4 already saves a file, maybe you were thinking about command + shift + control + 3?
- filoleg 3y agoIIRC Cmd+shift+4 by default stores to a file, but it is easily changeable in settings. Mine has been set to store to clipboard since a long time ago (since i mostly ever take them to send to someone in chat or to insert into my own notes, for which clipboard is exactly what i need). To change it: open Screenshot app (either cmd+shift+5 or from the app launcher), click Options in the center bar, and set "Save to" to "clipboard". Now, all screenshots in the future will be going by default to clipboard. You can also pick many other destinations for saving, including any arbitrary directory or many other apps (e.g., mail, preview, etc.). After some googling TIL, apparently if you use Ctrl key modifier with any screenshot shortcuts (cmd+shift+3/4), it will store to clipboard regardless of your setting. Kinda nifty for those who switch between storing to file/clipboard all the time.
- 3y ago
- penjelly 3y agowait caffeinate exists natively? ive been using a third party caffeine tool for the longest time..
- drooopy 3y agoThat's surprising to me as well. I had no idea that caffeinate existed as a native tool on my mac. I've been relying on "Jolt of Caffeine" for the past 3 years.
- hoosieree 3y agoNow if only I could remember how to spell caffeinate.
- plorkyeran 3y agoI've only ever tab-completed it from caff.
- samstave 3y agoJust make an alias to its other, easier to spell name `Methyltheobromine`. Simple.
- desro 3y agoI'm a 'trimethylxanthine' guy myself.
- sandyarmstrong 3y agoYeah, I was thrilled when I discovered this for myself a few months ago! It's so useful in long-running scripts.
- jkubicek 3y agoFor a long time I used an app for this as well, but the app was just a thin wrapper around the CLI tool
- 3y ago
- louzell 3y agoopensnoop is also a good one that usually stays under the radar
- 29athrowaway 3y agopandoc is the definitive document converter.
- lasermike026 3y agoWow! So cool! Thanks!
- alwillis 3y agoMy latest discovery is being able to manage Xcode simulators from the command line [1]. [1]: https://developer.apple.com/documentation/xcode/installing-additional-simulator-runtimes#Install-and-manage-Simulator-runtimes-from-the-command-line https://developer.apple.com/documentation/xcode/installing-a...
- bpye 3y agoCaffeinate is definitely the one I miss most on Windows. Super handy to keep your machine awake whilst some task is ongoing.
- perfect-blue 3y agoI’ve been looking for a better way to do this than just setting my PC to never sleep. Thanks for this. Now I need to find a Mac alternative as well.
- philbarr 3y agocaffeinate is on Mac. caffeinate -d -i -u -s
- perfect-blue 3y agoThanks very much for this.
- lattalayta 3y agokeeping you awake wraps this up in a menu bar icon that makes it easy to toggle on or off https://keepingyouawake.app/ https://keepingyouawake.app/
- redacted 3y agoIf you're able to install PowerToys it includes a utility for this https://learn.microsoft.com/en-us/windows/powertoys/awake https://learn.microsoft.com/en-us/windows/powertoys/awake
- Alifatisk 3y agoI believe you can still get it, if not, there are similar like Amphetamine
- jimt1234 3y agoAmphetamine has been my go-to app for keeping my Mac alive, especially since Apple tried to remove it from the App Store because, according to [someone?], the name violated App Store rules. https://apps.apple.com/us/app/amphetamine/id937984704 https://apps.apple.com/us/app/amphetamine/id937984704
- varispeed 3y agoInteresting so many useful commands, but they didn't have time to fix basics like scroll wheel, so you have to install 3rd party apps to set it independently from the touch pad and then it still manages to swap it around at random times. Am I the only one who finds macOS so annoying? I mean the apps for scroll wheel, alt-tab and what not...
- KyleBerezin 3y agoThe issues I have are touch-dragging with the touchpad, and no window docking. Docking I fixed by buying 'Magnet', touch dragging is still annoying. They have a setting that is supposed to enable 'double tap drag' like windows, but when you let go, it keeps dragging for some random amount of time, making it unusable.
- sbuk 3y agoSettings > Accessibility > Pointer Control > Trackpad Options... Three-Finger Drag works really well and is surprisingly easy to get used to doing.
- Hamuko 3y agoYou can use `say` to recreate your own Serial Experiments Lain intros. say -v Whisper "Weird: Layer zero one"
- blacksmith_tb 3y agoYou may have to install extra voices somehow, looking at the manpage for say, it seems like 'say -v ?' would list the voices installed, but I don't seem to have any (like Whisper), though plain old 'say "hello world"' does do a robotic voice which must be the default.
- Hamuko 3y agoYou can install additional voices in System Settings → Accessibility → Spoken Content → System voice → Manage voices (in Ventura). "Whisper" is listed under "English (US) - Novelty".
- blacksmith_tb 3y agoThanks, I found those with some digging, I see that even just adding Whisper it's a 3.8GB dl, mostly to upgrade the default voice apparently - I guess that's why it isn't all included by default I guess!
- frankjr 3y agoNot sure if you can install additional voices using the command line, but the way you do it in the UI is Preferences -> Accessibility -> Spoken Content, then select customize in the voice selector and finally select the voice you want to add.
- riobard 3y agoFor audio there're also `afinfo` to probe metadata and `afconvert` to convert between different codec/container formats. I use them for podcast post-processing and archiving workflow. macOS 13 Ventura ships with a customized `iperf3` called `iperf3-darwin` adding features like QUIC/L4S/MPTCP.
- Alifatisk 3y agoQUIC already? Cool
- rogual 3y agoA fun one I use surprisingly often is open -h AppKit.h to open any system header file (or I guess any header in the standard include path? It finds stuff from Homebrew too.)
- daneel_w 3y agoafconvert(1) lets you convert between various audio formats - most noteworthy is that it gives you access to Core Audio's superior AAC encoder without having to use iTunes/Music: afconvert music.wav -o music_160kbps_aac.m4a -b 160000 -q 127 -s 2 -f m4af -d 'aac ' lipo(1) lets you operate (replace/extract/thin/etc) on executables and libraries to tailor their supported architectures: lipo <universal exe/dylib> -thin arm64e -output <new apple silicon-only exe/dylib>
- daneel_w 3y agoAlso, using hdiutil(1) and diskutil(8) to create a RAM-disk: # 500 megabytes disk image mb=$((500*2048)) diskutil eraseVolume ExFAT my_ramdisk `hdiutil attach -nomount ram://$mb`
- efitz 3y agoSomeone should turn this HN discussion into a gist.
- llimllib 3y agohere's my notes from reading the comments: https://notes.billmill.org/computer_usage/mac_os/mac_os_command_line_programs.html https://notes.billmill.org/computer_usage/mac_os/mac_os_comm...
- renewiltord 3y agoI use: ``` #!/usr/bin/env bash set -u title=${2:-Shell} msg=$1 osascript -e "display notification \"$1\" with title \"$title\"" ``` As `~/bin/,notify` and put it at the end of long-running commands: ``` run_this_program && ,notify "Long program is done!" ```
- Svetlitski 3y agoI can’t help but ask, why “,notify” and not just “notify”?
- renewiltord 3y agoI name all my personal programs prefixed by the comma. I learnt it from someone on lobste.rs. No Unix utilities use the prefix in their name and it is a valid filename. So I can type , and I am sure it's my program and I'm not running something else and it'll autocomplete among my list of programs.
- wpm 3y agoThis is a very cool idea, I always hesitate to add a lot of aliases to my zshrc since I never want to step on any toes.
- inanutshellus 3y agoan upvote wasn't enough! this is cool, thanks for sharing.
- dcow 3y agoI’m surprised TFA doesn’t mention `plutil` and its counterpart `PlistBuddy`. They’re like the `jq` of macOS. https://scriptingosx.com/2016/11/editing-property-lists/ https://scriptingosx.com/2016/11/editing-property-lists/
- sovietswag 3y agoNeeds to mention afplay for playing audio! You can easily use this to make a command-line MP3 player. Others have mentioned the “say” utility for speech synthesis. There is a lot you can do with it, it supports the TUNE format, which allows you to "shape the overall melody and timing of an utterance... for example ... to make an utterance sound as if it is spoken with emotion". See: Apple's Speech Synthesis Programming Guide, https://josh8.com/blog/img/speech-synthesis.pdf https://josh8.com/blog/img/speech-synthesis.pdf I also wrote more about this here: https://josh8.com/blog/commandline-audio-mac.html https://josh8.com/blog/commandline-audio-mac.html
- kaycey2022 3y agoThank you for the article :) One small correction, the command to list the voices is `say -v '?'`
- microtherion 3y agoUnfortunately, the TUNE format turned out to be a bit of an evolutionary dead end; the last generation of Speech Synthesis that supports it is the Alex voice which shipped in 2007, and it's highly unlikely in my opinion that we'll ever see it again — pinpoint control of synthesis and naturalness are inherently in tension, and the latter is a lot more valuable.
- IggleSniggle 3y agoIt is unfortunate. But Alex does sound pretty good! Not up to 2023 standards maybe but still pretty good.
- manifoldgeo 3y agoThanks for posting! I'm always glad when I discover good blogs like yours.
- codetrotter 3y agoShoutout 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 situation. https://apple.stackexchange.com/questions/411544/cant-reclaim-empty-space-on-main-macos-partition-macos-mojave https://apple.stackexchange.com/questions/411544/cant-reclai... Now the disk can be fully utilised by macOS again.
- wpm 3y ago`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.
- IggleSniggle 3y agoI still open it sometimes thinking it's going to be a great experience, forgetting about this.
- MobiusHorizons 3y agoI didn’t know about textutil before, I’ll have to try that. Does that use the same backend as pages for word documents? How good is the conversion?
- tngranados 3y agoI didn't know about `taskpolicy`, I'll add it to my list. It will be handy now that it's getting hot around here for long running commands that I don't mind waiting for, Apple Silicon Macs run cooler than Intel's but they can still get very hot when maxed out.
- knodi123 3y ago> open - open files and applications And urls! I use that one in a lot of my scripts. We have a ticket-based workflow, and I can parse out the ticket number from the current git branch, and open the ticket or create a merge requests without having to do anything complicated.
- kart23 3y agoCUPS tools are also awesome. https://opensource.apple.com/source/cups/cups-450/cups/doc/help/options.html https://opensource.apple.com/source/cups/cups-450/cups/doc/h...
- strogonoff 3y agoYou can use sips together with iconutil to generate a complete .icns file for your app from a single 1024 by 1024 PNG without any third party software: mkdir MyIcon.iconset cp Icon1024.png MyIcon.iconset/icon_512x512@2x.png sips -z 16 16 Icon1024.png --out MyIcon.iconset/icon_16x16.png sips -z 32 32 Icon1024.png --out MyIcon.iconset/icon_16x16@2x.png sips -z 32 32 Icon1024.png --out MyIcon.iconset/icon_32x32.png sips -z 64 64 Icon1024.png --out MyIcon.iconset/icon_32x32@2x.png sips -z 128 128 Icon1024.png --out MyIcon.iconset/icon_128x128.png sips -z 256 256 Icon1024.png --out MyIcon.iconset/icon_128x128@2x.png sips -z 256 256 Icon1024.png --out MyIcon.iconset/icon_256x256.png sips -z 512 512 Icon1024.png --out MyIcon.iconset/icon_256x256@2x.png sips -z 512 512 Icon1024.png --out MyIcon.iconset/icon_512x512.png iconutil -c icns MyIcon.iconset As a bonus, generate .ico with ffmpeg: ffmpeg -i MyIcon.iconset/icon_256x256.png icon.ico Incidentally, does anyone know enough about the way sips scales PNGs to confirm that it makes sense to create the 16px version straight from 1024px, as opposed to basing it off 32px (and all the way up)? I.e., is it better to downscale in fewer steps (as currently) or in smaller steps?
- photonerd 3y agoadditional bonus, you can input an SVG at the start if you use qlmanage first instead of the cp command: qlmanage -t -s 1024x1024 -o MyIcon.iconset/Icon1024.png icon.svg
- strogonoff 3y agoNote of caution: if qlmanage uses QuickLook SVG rendering, YMMV. I recently had to deal with SVGs that render broken in Finder but correctly in, say, Affinity or Adobe tools. Rasterization feels sufficiently finicky that I personally would consider it part of designer’s workflow rather than automated conversion pipeline; but then some would say the same about raster versions at different sizes, so in the end it depends on what you can and want spend resources at. If it does work for you, though, you could generate every size from SVG directly and skip sips altogether (but you should check both methods to see which gives you a better quality icon, at small sizes single pixels can matter and so it would depend on how qlmanage handles rasterization to different sizes).
- tommica 3y agoOh, the `say` command is really damn useful to know about!
- simscitizen 3y agodtrace and the DTrace Toolkit scripts are also quite useful for understanding and debugging things, e.g. `opensnoop -a` to print the result of all open syscalls on the system.
- Jayakumark 3y ago[flagged]
- saurabhsharan 3y agoHi, author of the post here. No part of this post was generated via ChatGPT (or any other AI). I had been maintaining my own list of commands I've used over the years and decided to publish it on my website.
- lastangryman 3y agoI find it extremely upsetting that `networkQuality` is the only command that is not entirely lowercase. How did this get through PR??
- RandallBrown 3y agoThe say command has one of my favorite pieces of that famous Apple polish. If you type `say os x`, it'll actually speak "oh es ten".
- unsupp0rted 3y agoIt says "oh es ex" for all variations I've tried
- _diyar 3y agoCapitalizing the phrase made it work for me > say OS X Edit: Late 2016 MBP on 12.6.6 Monterey
- rootusrootus 3y agoInteresting. Says 'OS 10" on my Ventura 13.4 macbook.
- fredoralive 3y agoI'll go for the somewhat obsolete `drutil eject` as Mac OS can be sometimes rather reluctant to eject cycle optical drives if it doesn't actually think a disc in in them. Although nowadays you'll probably be using a 3rd party tray load drive with an eject button instead of a no-button slot loading Apple one.
- reaperducer 3y agoMy LG Blu-Ray drive ignores its eject button if it's connected to a Mac, unless the drive is empty, so I use this, too.
- js2 3y agoSome that were missed: diskutil: modify, verify and repair local disk hdiutil: manipulate disk images (attach, verify, create, etc) dscl: Directory Service command line utility (manage users and groups) scutil: Manage system configuration parameters (useful for checking current DNS configuration and checking reachability to a host). sysadminctl: It's a secret! No man page. Run without options to get a usage message, but even the usage is apparently incomplete. It's a grab-bag of functionality. I use for adding/removing a temporary build user as part of a CI/CD setup.
- verst 3y agoI like to hide all icons or folders on my Desktop when I need to be more productive or when I'm presenting. This can be done with: # hide desktop icons and folders defaults write com.apple.finder CreateDesktop 0 killall Finder # restarting Finder is required # unhide desktop icons and folders defaults write com.apple.finder CreateDesktop 1 killall Finder # restarting Finder is required I made myself a convenient bash alias for this which lets me simply toggle the desktop on and off Here is a gist: https://gist.github.com/berndverst/6f58c0d6aedddb6c06c23e57dd50d198 https://gist.github.com/berndverst/6f58c0d6aedddb6c06c23e57d... toggledesktop () { if [[ $(defaults read com.apple.finder CreateDesktop) -eq "0" ]] then export SHOWDESKTOP=1; echo "Unhiding Desktop icons" else export SHOWDESKTOP=0; echo "Hiding Desktop icons" fi defaults write com.apple.finder CreateDesktop $SHOWDESKTOP killall Finder }
- IggleSniggle 3y agoI've used this one for over a decade now. When I was a teacher, I even assigned it to a key-combo. Consider pairing with a few other things you might want in a presentation setting
- desro 3y agoTurning off the desktop is one of the first things I do when setting up a new Mac. I still use ~/Desktop often enough that it's one of two folders I keep in the Dock (the other being ~/Downloads). Although: the introduction of Stacks to the macOS desktop was a great thing — I always show that feature to anyone whose Desktop is helplessly cluttered with files.
- balls187 3y ago“say” with my laptop connected to my home bluetooth speakers is a lot of fun with my kids.
- verst 3y agoA 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-defaults.com/#%F0%9F%99%8B-what-s-a-defaults-command https://macos-defaults.com/#%F0%9F%99%8B-what-s-a-defaults-c...
- llimllib 3y agohttps://github.com/zcutlip/prefsniff 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
- andelink 3y agoPretty cool tool it looks like. Gonna try using this. Also has good resources in the README.
- joshSzep 3y ago`caffeinate` is a game changer. Now I can keep my Slack status green without sitting in an empty zoom room. #WFHLife ;)
- lkuty 3y agoI use `caffeinate -dsim` permanently. In short I ask the computer to avoid any kind of sleep. -d Create an assertion to prevent the display from sleeping. -i Create an assertion to prevent the system from idle sleeping. -m Create an assertion to prevent the disk from idle sleeping. -s Create an assertion to prevent the system from sleeping. This assertion is valid only when system is running on AC power.
- theshrike79 3y agoAmphetamine does the same thing, but with a task bar icon and better usability: https://apps.apple.com/us/app/amphetamine/id937984704?mt=12 https://apps.apple.com/us/app/amphetamine/id937984704?mt=12
- datavirtue 3y agoOr a full screen YouTube Mozart video that lasts for six hours
- deleted 3y ago[deleted]
- massysett 3y agoIs 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?
- saurabhsharan 3y agoHi, author here. There isn't any official canonical documentation that I know of, outside of the individual man pages. This was a list of commands I've been maintaining for myself over the years and thought it would be useful to share. If you want more like this, I also have another page full of lesser well-known macOS tips and tricks: https://saurabhs.org/macos-tips https://saurabhs.org/macos-tips
- tlh 3y agoOh my, and a bucket load of iOS tips too! TIL you can tap and drag with 2 fingers to multi-select list items in mail and notes, etc Bless you for finding and collating
- andelink 3y agoI'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 https://news.ycombinator.com/item?id=36492487
- kevwil 3y agoThe `security` tool is handy too. I like the ability to store passwords in the `login` Keychain and automate using them in the terminal using `security find-generic-password`. security find-generic-password -gw -l "${keychain_id}" Super helpful for VPN automation scripts, easy logins to things like Vault, etc. The security tool has tons of other handy functions as well.
- asveikau 3y agoNot on the list, but I think `fs_usage` is an interesting one. Like a firehose of disk activity.
- thadk 3y agoHaving ChatGPT or equivalent create a basic Makefile for these commands (and other commands) is a quick way to preserve your process for later. You can show it your file structure first too.
- apocalyptic0n3 3y ago`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.
- baliex 3y agoTo open a new finder window in the current directory in a terminal: alias finder='open .'
- Kyuuketsuki 3y agoOne flag also not mentioned is -n, which allows you to run the same application in more than one instance. Historically the single most used utility for me, though the number of applications that have had design problems bad enough to warrant it has gone down.
- Sujeto 3y agoI made a script to open files with rofi https://github.com/davatorium/rofi https://github.com/davatorium/rofi Looks like this: https://i.imgur.com/Hm9TGeV.jpg https://i.imgur.com/Hm9TGeV.jpg In a vscode terminal I just use the alias "o" and it opens that at the correct location, then I can navigate and pick a file to open in the editor.
- movedx 3y ago> 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?
- andelink 3y agoIn 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.
- apocalyptic0n3 3y agoI forget that's an option. I really dislike that and prefer for new tabs to open in my home directory. So having my `tab` alias that I use a couple times a week and opening the other 100 tabs in my home directory fits my workflow.
- babbledabbler 3y agosay --rate=500 "Peter Piper picked a peck of pickled peppers. A peck of pickled peppers Peter Piper picked. If Peter Piper picked a peck of pickled peppers, Where’s the peck of pickled peppers Peter Piper picked?"
- miohtama 3y agosay - text-to-speech engine: I would have expected that at the era of AI this would sound a bit better than the Commodore 64 speech synthesis from 80s.
- meepmorp 3y agoIt's dependent on the voice you pick in system settings. If you choose one of the siri voices for the system voice (not in the siri settings, iirc), it sounds much more natural.
- xenodium 3y agoA couple of built-in I didn't see: macOS software versions: sw_vers macOS hardware overview: system_profiler SPHardwareDataType Convert binary plist to xml plutil -convert xml1 -o out.xml in.plist A couple of lesser known, but also handy ones to install: brew install dark-mode brew install duti > screencapture - take screenshots Big fan of screencapture. I wanted something similar but for capturing window videos, so I built https://github.com/xenodium/macosrec https://github.com/xenodium/macosrec I often wrap command line utilites with Emacs functions (don't need to remember invocation flags/structure but also enables batch invocations) https://xenodium.com/recordscreenshot-windows-the-lazy-way https://xenodium.com/recordscreenshot-windows-the-lazy-way
- Crontab 3y agoWhen a new MacOS release comes out, one of the first things I look for is adds and changes to the command line tools. Sadly they are not the things that most people care about on a new release.
- silly_squidward 3y agoYou should check out "um" https://github.com/promptops/cli https://github.com/promptops/cli for when you can't remember the command/parameters. ~ um prevent my mac from sleeping for 30m caffeinate -u -t 1800 don't see what you're looking for? try providing more context
- defatigable 3y agoHey, this looks awesome. Thanks so much for the pointer.
- koinedad 3y agopbcopy and pbpaste are soooo helpful
- SpaghettiX 3y agoThere is an even longer and useful list on https://git.herrbischoff.com/awesome-macos-command-line/about/ https://git.herrbischoff.com/awesome-macos-command-line/abou...
- thomasahle 3y agoI 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 files, command history, etc. 4. tldr: Community-driven man pages with practical examples. 5. ripgrep (rg): Extremely fast text search tool, recursively searches directories for a regex pattern. 6. tmux: Terminal multiplexer to run multiple terminal sessions within a single window. 7. autoenv: Automatically source environment variables based on the current directory. 8. hub: Extends git with extra features and commands for GitHub. 9. ncdu: Disk usage analyzer with an ncurses interface. 10. jq: Lightweight command-line JSON processor. 11. sshfs: Mount a remote filesystem using SFTP. 12. watch: Execute a program periodically, showing output fullscreen. 13. fd: Simpler and faster alternative to `find`. 14. z: Jump around directories based on frequent use. 15. lazygit: Simple terminal UI for git commands. Most of them I already knew, but z seems like an interesting tool. The docs are here <https://github.com/rupa/z https://github.com/rupa/z>: z foo cd to most frecent dir matching foo z foo bar cd to most frecent dir matching foo, then bar z -r foo cd to highest ranked dir matching foo z -t foo cd to most recently accessed dir matching foo z -l foo list all dirs matching foo (by frecency) Might start using it, if I'm not too stuck in my habits.
- tambourine_man 3y ago>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
- daotoad 3y agoIf you like `z`, you should check out my `tutu`. https://github.com/daotoad/tutu https://github.com/daotoad/tutu
- msie 3y agojson_pp
- tambourine_man 3y agoIn the best HN tradition, the list in the article is good, but the comments section is where the gold nuggets are.
- FabHK 3y agoAnother one that comes in handy occasionally is afconvert to convert audio files. I like to add audio files (eg audio books, or guided meditations) to iTunes/Music or Books, and they are a little bit finicky in terms of what they accept and sync (I've had problems with files converted with ffmpeg). I use this to convert an mp3 to a variable rate m4b for Books: afconvert -v -s 3 -f m4bf meditation1.mp3
- oregano 3y agoAt the risk of sounding like an idiot, can someone please explain why I cannot use `networkQuality` when zsh is my shell? Is there an alternative for zsh?
- ernst_mulder 3y agoMany thanks OP for the couple of commands I did not yet know. Especially `pbcopy` and `pbpaste`, those are going to be very useful. Here are a couple of commands I use quite a lot. lsof -p <PID> Lists the open files of the process with process ID <PID>. Very very useful. fs_usage -w <PID> This one is mentioned by others here as well, but followed by a <PID> it shows all filesystem activity of the given process. Useful if you want to know where specific settings of an application are stored. top -u Obvious what this does, standard command. Sorted by CPU usage. <some command> | open -ft Opens the <some command>'s result in your default text editor. system_profiler Very useful for finding out stuff. E.g. system_profiler SPNVMeDataType SPSerialATADataType | grep 'BSD Name: disk[0-9]$' | sed 's/.\* //' Gives the device name of all your system's SATA and NVMe SSD's. sysctl -a Another way to find out stuff. E.g. sysctl -a | grep hw.memsize Shows the amount of physical memory in your system. tmutil Very powerful for managing Time Machine as mentioned by others here. Also useful for other stuff. There is a lot of File I/O on my system due to running at least five VM's all the time. This produces big snapshots. Every now and then my system hung up due to running out of space because of these snapshots. Now I'm running my own "snapshottaper" daemon running every ten minutes keeping only the last 4 snapshots and deleting the rest, using "tmutil listlocalsnapshotdates" and "tmutil deletelocalsnapshots" which eliminates that issue (which is a bug imho). And some of my often used (tcsh) aliases: proc, aliased to 'ps -axww -o pid,user,command | grep -v "grep -i" | grep -i \!\* | sed "s/^\ *//"' Filter the list of running processes for a specific string, e.g. use "proc adobe" to find all running processes by Adobe. I use this a lot. spf, aliased to 'dig \!* txt | grep "v=spf"' Useful for finding SPF records for a given domain, e.g. 'spf apple.com'. mx, aliased to 'dig \!\* mx | grep -v "^;..*" | grep "IN\WMX"' Same, but for MX records (I maintain e-mail servers, hence these two). est, aliased to 'netstat -n | grep -i proto ; netstat -n | grep ESTABLISHED | grep -v 127.0.0.1' List all currently open network connections. listen, aliased to 'sudo echo -n; sudo lsof -i4 -n -P | grep "\*:" | sed "s/IPv4.*://" | grep LISTEN | sort -n --key=5 | sed "s/ (LISTEN)//" | awk BEGIN\ \{print\ \"COMMAND\ \ \ \ \ \ \ \ \ \ \ PID\ \ \ \ \ \ \ USER\ \ \ \ \ \ \ PORT\"\}\ \{printf\ \"%-10s\ %10s\ %10s\ %10s\\n\"\,\ \$1\,\ \$2\,\ \$3\,\ \$5\}' List all processes currently listening on network ports. router, aliased to 'netstat -rn -f inet | grep default | grep -v link | awk \{print\ \$2\} | head -1' List the currently used internet router. (I hope all escape characters and such survive posting this, please excuse me if they don't, also my default command shell is tcsh for historical reasons, it was my default shell in the early 1990's. Yes my shell scripts are all #!/bin/sh) Other than these, I really like using AppleScript and shell scripts together. Using AppleScript I now have my own GUI tools for making disk images using drag-and-drop, compacting sparse images, performing default settings for new installations, switching between virtual machines whilst hiding others, etc.
- d4rkp4ttern 3y agoI recently discovered snippet-management tools, which I didn't know I needed. I'm trying Maccy and Paste. Curious which ones others love.
- revicon 3y agoI wrote this a while back to document managing WIFI connections using the command line. https://www.mattcrampton.com/blog/managing_wifi_connections_using_the_mac_osx_terminal_command_line/ https://www.mattcrampton.com/blog/managing_wifi_connections_... I use these commands a lot when I'm in a coffeeshop and I'm trying to fine-grain control which wifi connection my laptop is using and dealing with passwords. IMO OSX's UI for wifi network picking is clunky when you're in an area with >50 wifi networks in range, command line tools are much easier to deal with.
- x3874 3y ago[dupe]
- bhal 3y agoGreat list, working with Mac a long time and found some good things here. This might be useful too: # cd to frontmost open finder folder (in Terminal cd to the current top finder window) cdf() { cd "`osascript -e 'tell app "Finder" to POSIX path of (insertion location as alias)'`"; pwd; } # Copy the frontmost open finder folder Path from Terminal to the Clipboard in MacOS: cpf() { echo "`osascript -e 'tell app "Finder" to POSIX path of (insertion location as alias)'`"|pbcopy; } # open manpage in preview app: pman() { mandoc -T pdf "$(/usr/bin/man -w $@)" | open -fa Preview; } # Function to delete a given line in ssh known_hosts file: xho() { line=$1;tFile="$HOME/.ssh/known_hosts";sed -e "${line}d" -i ".tmp" "$tFile";}