Earlier quoted context omitted.
I’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.
caffeinate is on Mac. caffeinate -d -i -u -s
macOS command-line tools you might not know about
171–180 of 454 posts
Re: macOS command-line tools you might not know about
#172`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.
Re: macOS command-line tools you might not know about
#173Earlier quoted context omitted.
Those are so useful that I wrote trivial shell functions that do the same under Linux.
Since I'm bouncing between OSX and Linux a lot, I have a shell script with the same name on each that boils down to: if [ `uname` == "Darwin" ]; then pbcopy else xsel --clipboard fi
Re: macOS command-line tools you might not know about
#174Re: macOS command-line tools you might not know about
#175Caffeinate is definitely the one I miss most on Windows. Super handy to keep your machine awake whilst some task is ongoing.
I’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.
Re: macOS command-line tools you might not know about
#176When mentioning `open` they should have noted that `open ` will open the given file with its associated app. It’s indispensable.
Re: macOS command-line tools you might not know about
#177`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.
Re: macOS command-line tools you might not know about
#178Years 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 ” 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.
"So, I used the msf module that invokes `say` on a client's laptop"
Re: macOS command-line tools you might not know about
#179``` #!/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!" ```
Re: macOS command-line tools you might not know about
#180Earlier quoted context omitted.
Especially 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.
I 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 .'
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