MacOS – Striving to become power user on OS X (coming from Windows)

homebrewmacosterminal

I'm a long time Windows developer guy & did lots of lower-level stuff (hesitate to say power user). I'm very proficient on the command line and using PowerShell… but now that I've moved over to OS X I feel lost at times. I'm not talking about learning the stuff on https://www.apple.com/support/macbasics/pctomac/ rather, to start I'd like to get a better understanding of the organization of the file system & working in the terminal.

I see /usr and folders in there but my lack of understanding in what I'm typing when I go to install some developer utilities / tools (think stuff that involves Homebrew) feels like I've missed a lot of steps.

Any suggestions on where to crash course?

Best Answer

I know almost nothing about Windows, but I think the equivalent of PowerShell on the Mac is AppleScript, not bash. The equivalent of bash would be MS-DOS Prompt, right? With PowerShell, you’re scripting the Windows GUI and apps, right? That is AppleScript on the Mac. So you might get more practical — and immediate — results from using the AppleScript Editor app rather than the Terminal app. Terminal enables you to script Unix command-line apps and become a Unix power user, but AppleScript Editor enables you to script both Mac GUI apps and Unix command-line apps, and become a Mac OS X power user.

To give you an idea of what I’m talking about, you can Copy/Paste this AppleScript into your AppleScript Editor and tap the Run button at the top of the window. The HTML source of the current Web page that is showing in Safari will appear in a new document in TextEdit.

tell application "Safari"
    activate
    if document 1 exists then
        set theHTMLSource to the source of document 1
        tell application "TextEdit"
            activate
            make new document with properties {text:theHTMLSource}
        end tell
    end if
end tell

This is a very basic example, but most AppleScripts are just expansions of this core idea of multiple Mac apps working together like a player piano. In-between Safari getting the HTML source and TextEdit rendering it, you could use the “do shell script” command to apply a PHP function to the source. After it is showing in TextEdit, you could use the “save” command to save the source as an HTML document to a particular file folder.

A key thing is that right away, you’re automating the apps you use every day. Anything that can be described as “grunt work” can be automated into a single step with AppleScript, so that you save a lot of time and trouble as you work. And right away, you’re not just using Mac apps, you’re also making Mac apps, because any AppleScript can be Saved as a standalone Mac app.

Ultimately, you do end up learning the Unix shell, but only the parts that you find interesting and useful to your work. For example, if you’re writing an AppleScript and you want it to download a file from a URL, you can have the AppleScript run the Unix “curl” command, but after that the AppleScript might open that downloaded file in Photoshop and add borders to it and reduce it to a certain size and export a Web-ready JPEG, and finally your AppleScript could use an FTP app to upload that JPEG to a particular Web server.

The whole Mac is fair game in one way or another with AppleScript.