How to use the Terminal to change the look of your Mac and speed up your work

Posted:
in General Discussion edited February 6
It can be dangerous if you're not careful, but alongside immense yet arcane power tricks, macOS Mojave's Terminal app has benefits for every Mac user. If you're a beginner, AppleInsider has some suggestions for you.

Apple's Terminal app icon
Apple's Terminal app icon


Terminal is one of the most useful apps on a Mac but using it feels wrong if you love a graphic user interface. It's a Mac -- this is the computer that defined graphical interfaces, and it is what took us away from typing barely comprehensible commands into computers with glowing text-based screens. Yet, decades after we learned to drag and drop, still you can open Terminal on any Mac and go right back to typing instructions.

Most people who use Terminal do so intensely and for a gigantic range of features that most Mac users neither know nor care about. If you're a beginning user, there's a good chance you haven't even heard of the Terminal.

And if you're in the middle, if you've had a Mac for a while, then it's likely that you have heard of it but specifically that what you've heard is that it's dangerous. You can type commands into it that will wreck your Mac, for instance. The Terminal is far from a self-destruct button, but it isn't so safe that we'll press on without giving you a disclaimer.

We are going to show you Terminal commands that are likely to be useful to every user, but yes, you need to type them in carefully.





With that said, though, here's the cold, hard and very un-Mac-like truth. You can do things on your Mac in Terminal, you can do useful work, that you can't in any other way. And, that includes changing visual elements such as the Dock and it includes getting you finer control over screengrabs.

Screengrabs

Apple added new ways of taking an image of whatever's on your screen with the release of macOS Mojave but it didn't take any away. So it's still possible to very quickly grab an image of a specific document or Finder window. Or at least it's quick if you're happy with how the Mac handles it.

You just hold down Command and Shift, then tap the digit 4. Your cursor changes to crosshairs and you could drag it across the window to say what bit you want to capture, but you can also tap the space bar. When you do that, the crosshairs turn to an icon of a camera and now when you tap the space bar, you save an image of just that window.

Except that isn't quite true. You do get just the window you chose, you don't get anything else from your Mac's screen -- but unfortunately you do get a drop-shadow background border that Apple chooses to add.

Depending on what you open the image in, the border will be black or off-white but there will always be a border
Depending on what you open the image in, the border will be black or off-white but there will always be a border


The border that Apple adds does give you room to make annotations but if you just want the window, you can tell the Mac to ditch the border. You just have to do it through Terminal.

Opening and using Terminal

Terminal is an app on your Mac and you can open it via Spotlight or by drilling down into the Utilities folder within Applications.

If you are the main or admin user of your Mac, then launching Terminal will open a window that shows you a single command line prompt. It will be the name of your Mac's startup disk followed by your username with a dollar sign at the end. Then there'll be a flashing cursor waiting for you to type something.

The Terminal app before you enter any commands. Hudson-Yards is the Mac's name, williamgallagher the user's.
The Terminal app before you enter any commands. Hudson-Yards is the Mac's name, williamgallagher the user's.


Type the following precisely -- or better yet copy and paste it.

defaults write com.apple.screencapture disable-shadow -bool TRUE

Hit Return and now type:

killall SystemUIServer

And Return again.

That first line changes a default option in the Mac. In all the examples you're going to see, there will be a word in all-caps such as TRUE or FALSE, YES or NO. In each case, you type the command with one to switch the option on or with the other to switch it off.

You don't have to write those words in all capitals but it's handy to. It means you can see immediately whether you've switched something on or off.

Note that you do have to write everything else in precisely the right mix of upper and lowercase. While Killall works just as well as killall, the command killall Dock will work and killall dock won't.

This killall command is Terminal's equivalent of force-quitting an app and immediately relaunching it. None of these Terminal commands need you to restart your Mac but most of them do need you to restart part of it and that's what the killall command does.

When you've typed or copied-and-pasted correctly and then hit Return, you get the command line prompt again and usually nothing else. If you're done, you can now type exit, which will let Terminal neatly finish up, and then File, Quit.

That's what you will always do: open Terminal, type or paste a specific command or two, then get out. Don't leave Terminal open if you're not using it.

And having now delayed you long enough, here's the result of typing that command ending in disable-shadow -bool TRUE.

After using the Terminal command, a screengrab of a window does no longer gains an extra border
After using the Terminal command, a screengrab of a window does no longer gains an extra border


From now on, any Finder or document window that you take a screen grab of, will look like this. No more borders -- until you use Terminal to enter the opposite commands, which are:

defaults write com.apple.screencapture disable-shadow -bool FALSE
killall SystemUIServer

Speaking of screenshots

When you take a screengrab of anything on macOS Mojave, you see the image briefly appear as an iOS-like thumbnail at the bottom right of your screen. Then it's always saved to your Desktop and it's always saved in PNG format.

The thumbnail is handy when you're just taking one shot and can see from it that you've got the bit of the screen you wanted. If you want to take several in a row, though, then it's a pain because macOS is not as smart as iOS.

Even if you still have the preview thumbnail on screen when you take another screengrab on your iPhone or iPad, iOS is clever enough to not show it. On macOS, you get the screengrab plus any preview thumbnail that happened to be open.

You don't need Terminal for everything.
You don't need Terminal for everything.


You don't need Terminal to switch this preview thumbnail off. Just hold down Command, Shift and tap 5. In the toolbar that appears, click on Options and then click to deselect Show Floating Thumbnail.

There is also an option in that same section to choose where you want all your screen grabs to be saved. What you can't control here or anywhere else on your Mac is what format the screengrab is saved in -- unless you use Terminal.

From within Terminal, you can say that you want these shots to always be saved in JPG, TIFF, BMP or just about any format you can think of, including PDF. Type or copy/paste this:

defaults write com.apple.screencapture type pdf

This is one that doesn't need a killall, it just works. And from now on, every screengrab will be saved to your Mac in PDF format. To change it back to PNG, write

defaults write com.apple.screencapture type png

There is one more thing you can do with screengrabs in Terminal that you cannot in any other way without third-party apps such as Hazel. Right now, your Mac will save a screengrab and begin its name with the word "Screenshot."

Changing the defaults from
Changing the defaults from "Screenshot..." to "Pretty Picture" or anything else you want such as a company or project name


To do this, type the following into Terminal.

defaults write com.apple.screencapture name "Pretty Picture"

You realize that you can change Pretty Picture to anything you like. It just has to be in speech marks. Notice, though, that in the image above, we've actually written this as:

defaults write com.apple.screencapture name "Pretty Picture"; killall SystemUIServer

That's the killall command put on the same line as the rest of the instruction. It's separated by a semi-colon and there's no functional difference between doing it like this or as two separate lines. It's just sometimes convenient to put it on one.

And that's especially the case when you want to do something briefly and then change it back. For Terminal has one trick to save you doing all this typing. At the command line prompt, press the up arrow on your keyboard. You'll see your previous command appear at the prompt. You can edit it there to change, say, the name of the screenshots or to switch TRUE to FALSE and then just Return.

The Dock will see you now

All of these screengrab options do speed up your work. You're no longer having to remove the border from a shot of a window, for instance, and you don't have to convert image formats or change names. That's great if you're working with screengrabs but there are also Terminal commands that can speed up how you use your Mac for everything.

They're all to do with the Dock. If you've already ditched the Dock in favor of a third-party app or actually no Dock at all, then they're no use. Yet if you just speed the Dock up, you might find it more appealing.

First, hide your Dock. Go to System Preferences, Dock and click on Automatically hide and show the Dock. With this set, then your Dock vanishes -- until you hover your cursor over the bottom of your screen. Then the Dock pops back up so in theory you get all the benefit of having it there but also the extra space that hiding it offers.

In practice, though, it tends to pop up quite slowly. You can instead go to Terminal and type:

defaults write com.apple.dock autohide-time-modifier -int 0
killall Dock

You can guess that this speeds things up but actually it makes the Dock appear instantly. It removes the animation effect and instead one moment your Dock isn't there, and the next it is.

This works whether or not you have the Dock at the bottom of the screen or to the side. And to get it back to appearing in the animated way that Apple intended, you use Terminal and enter this:

defaults delete com.apple.dock autohide-time-modifier
killall Dock

Space walk

If, on the other hand, you love the Dock so much that you use it to excess, you can also use Terminal to help organize it for you. Alongside regular app icons, you can create spacers which simply take up a slot in the Dock without doing anything.

As they're spaces, they can be hard to drag because you can't see any icon to click on. However, even if it takes you a few goes to find the right spot to click and hold, you can do it and that means you can position them anywhere in the Dock that you want.

Terminal can create spacers to help you organize your Dock
Terminal can create spacers to help you organize your Dock


You can group all of your writing apps together, for instance. To get one single spacer in your Dock, you enter the commands:

defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}'
killall Dock

Unusually, there's no place in that command for you to specify that you want two or more spacers. To get extra ones, you enter the exact same command again. And again. Until you've got as many as you need.

Equally, there's no version of this command for removing spacers but that's because you don't need one. Spacers in your Dock act like regular app icons in that you can drag them off until you see the word Remove. Again, it's hard to see where to click to drag like this but with your cursor anywhere near the spacer, you can right-click and get the functionally identical Remove from Dock option.

Take it from here

These commands all make visual changes to how your Mac looks or how it handles the filenames in screengrabs. The way that you've done these, though, is precisely the same way that you will go on to do more elaborate and potentially more useful, certainly much more powerful work in Terminal.

Using these same techniques and some different commands, you'll be able to force your Mac to rebuild a troublesome Spotlight index, for instance. You'll be able to keep your Mac awake, shut it down and make it automatically restart after a crash. These are all topics for another day, however.



Keep up with AppleInsider by downloading the AppleInsider app for iOS, and follow us on YouTube, Twitter @appleinsider and Facebook for live, late-breaking coverage. You can also check out our official Instagram account for exclusive photos.

Comments

  • Reply 1 of 20
    darkpawdarkpaw Posts: 130member
    What a coincidence: I posted a comment a couple of days ago saying I don't like William Gallagher's writing style, then I suggest a way of adding blank spaces into the Terminal. That comment got deleted without mention, and now suddenly my Terminal tip shows up in one of William Gallagher's posts...
    cornchip
  • Reply 2 of 20
    djsherlydjsherly Posts: 1,018member
    Notice that the difference is not just that we've removed -int 0 from the end. This command needs a change at the start too. Instead of defaults write com.apple.dock and so on, it needs to be defaults write com.apple.dock.

    It needs to be defaults *delete*
  • Reply 3 of 20
    copperfilecopperfile Posts: 4unconfirmed, member
    In Mojave 10.14.3, your Terminal command to make Dock instantly appear does not have any affect for me. (yes I did re-attempt and used "killall Dock" several times without any success) defaults write com.apple.dock autohide-time-modifier -int 0
    edited January 31
  • Reply 4 of 20
    deminsddeminsd Posts: 141member
    I tried the screen-shot function in Mojave (no changes, just doing a screen grab) and I do not get any borders.  The image area I lasso is what I get in my screenshot file.  Checked it in Preview and Photoshop.  

    For me, CMD-SHIFT-4 works as expected.  No borders.
  • Reply 5 of 20
    If you like these shortcuts and tricks maybe you would like to check out CLIX.app from Rixstep.com. They are a lot safer since in CLIX you have less risk of making spelling errors. They are superb programmers. (I am not one of them)
    winlundn
  • Reply 6 of 20
    iTerm2 is better.

    I like the built-in functionality of iTerm:


    jbishop1039
  • Reply 7 of 20
    TutTut said:
    If you like these shortcuts and tricks maybe you would like to check out CLIX.app from Rixstep.com. They are a lot safer since in CLIX you have less risk of making spelling errors. They are superb programmers. (I am not one of them)
    Thank you! This is very helpful to me.
  • Reply 8 of 20
    The new screengrab utility is fabulous. I use it many times per day for documenting and programming. It's not just for images but also for movies. The Apple employee who designed it should get a one million dollar award.
  • Reply 9 of 20
    The return of ResEdit?
  • Reply 10 of 20

    OK, Will, second try:


    What app is this?

  • Reply 11 of 20
    WilliamGallagherWilliamGallagher Posts: 5member, editor

    OK, Will, second try:


    What app is this?

    That's FileMaker Pro Advanced 17. Do you mean you asked me before? I didn't see that, sorry.

    William
    bestkeptsecret
  • Reply 12 of 20
    WilliamGallagherWilliamGallagher Posts: 5member, editor
    The return of ResEdit?

    ResEdit! I haven't thought of that in years. I loved that app.

    William
  • Reply 13 of 20
    WilliamGallagherWilliamGallagher Posts: 5member, editor

    deminsd said:
    I tried the screen-shot function in Mojave (no changes, just doing a screen grab) and I do not get any borders.  The image area I lasso is what I get in my screenshot file.  Checked it in Preview and Photoshop.  

    For me, CMD-SHIFT-4 works as expected.  No borders.
    "The image area I lasso is what I get..." may be the clue here. If you use Command-Shift-4 and then drag the crosshairs over the area you want, that's what you get. It's when before dragging it, you tell macOS to select the current window. So you press Command-Shift-4, then with your crosshair cursor over a particular window, you tap the space bar. The crosshairs turn to an icon of a camera and now when you click the mouse or tap the trackpad, macOS takes a shot of that window and only that window – but it adds a border.

    I did notice that when I loaded such an image into some apps, the border was displayed as black and in others it was transparent. But either way, it's a sizeable bezel around the window I want to screengrab and before I learned of this Terminal command, I used to have to lasso the bit I wanted.

    William

  • Reply 14 of 20
    WilliamGallagherWilliamGallagher Posts: 5member, editor

    In Mojave 10.14.3, your Terminal command to make Dock instantly appear does not have any affect for me. (yes I did re-attempt and used "killall Dock" several times without any success) defaults write com.apple.dock autohide-time-modifier -int 0
    I am on 10.14.2 and I have noticed that Apple has removed various useful Terminal commands over the years, so it's conceivable that it's gone now but it seems unlikely in just this small point update. Is anyone else here on 10.14.3 and can try it for me, please?

    Copperfile, did you email me about this? If that was you, then as I said in my reply, I copied the Terminal line out of your email and pasted it onto my Mac. It worked precisely the way it should.

    Did you definitely have the "Automatically hide and show the Dock" setting ticked to on? And I don't know that this could make any difference but are you the admin user of your particular Mac?

    William
  • Reply 15 of 20
    I did notice that when I loaded such an image into some apps, the border was displayed as black and in others it was transparent. But either way, it's a sizeable bezel around the window I want to screengrab and before I learned of this Terminal command, I used to have to lasso the bit I wanted.

    William


    Just to clarify this..
    It's not border, it's a drop shadow of the window with gradual black fill of 0-25% visibility. Picture viewer used black as background colour, so the shadow was not visible.
  • Reply 16 of 20
    Mike WuertheleMike Wuerthele Posts: 4,604administrator
    darkpaw said:
    What a coincidence: I posted a comment a couple of days ago saying I don't like William Gallagher's writing style, then I suggest a way of adding blank spaces into the Terminal. That comment got deleted without mention, and now suddenly my Terminal tip shows up in one of William Gallagher's posts...
    A series of Terminal articles was assigned to William on around the 5th of January. This one was turned in 10 days ago, well before your post.

    And, frankly, I don't care if you don't like William's writing style. It isn't a topic up for debate.
    edited February 1 williamlondon
  • Reply 17 of 20
    Speech marks? Is this a new term for quotes? 
    jasenj1
  • Reply 18 of 20
    Mike WuertheleMike Wuerthele Posts: 4,604administrator
    If you can't find your comment in this thread, feel free to read the commenting guidelines conveniently linked at the bottom of every forum page. For some of you, this is a repeat offense because you found the tip too beginner for you. As a reminder, AppleInsider is for everybody. If a tip isn't applicable to you because you already know how to do it, just move on, and refrain from commenting.

    For some of the rest of you, you're just being a jerk. We have forum rules, and we have them for a reason.
  • Reply 19 of 20
    Nice tips. I appreciate the way you say “hold down command and shift and then tap the digit 4,” as I’m often at a loss trying to explain keyboard commands to the uninitiated, your phrasing really spells out the proper way to chord it out. I’m apparently compelled to point out that Terminal doesn’t have a File menu to choose “Quit” from, and in fact it’s been since OS9 that File-> Quit has been the procedure, now it’s in the... Application menu I guess they call it? Anyhow, dig the tips and tricks articles, cheers.

  • Reply 20 of 20
    copperfilecopperfile Posts: 4unconfirmed, member
    I just discovered you can NOT be logged in as "Root" user to do this.
    Exit if Root and execute code as normal admin user and it works. :) 
    cornchip
Sign In or Register to comment.