Repost: 5 Terminal Hacker tips for the Mac

[This is a repost from my HackTheDay blog of 6 years ago. But these are rare-to-find tips that are still highly valuable.]

You don’t really need a reason to try out these Mac OSX tips and hacks. But they are fun, probably useful and definitely will get a nice reaction from your friends. They all involve typing some commands in the Terminal.app(each command is followed by the Enter key); if commands start with sudo, you might be asked to also type down your Mac administrator password(which you ought to have set when you first logged to your computer). For instructions on finding Terminal.app and tips on using it, see our great Terminal.app tutorial.

Tip #1. Quickly prevent your Mac from going to sleep

If you are doing something important but not interactive enough(reading an ebook/article or demoing a slideshow to your boss for instance) and get frustrated by your computer repeated attempts to go to sleep, there’s a quick and simple way to prevent this temporarily and without messing anything up: in Terminal, type down
pmset noidle
Just remember to type Ctrl+C (^C) in the same window when you’re done.

 

Tip #2. Organize your Dock with invisible spacers

To add a spacer to the applications (left) side of the Dock, run the following in the terminal:

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

You’ll need to run killall Dock afterwards in the terminal, to restart the Dock and see the changes.
The above spacer only gets inserted in the Icons section of the Dock. If you want to insert one in the Documents section on the right, you’ll need to run this command instead:

defaults write com.apple.dock persistent-others -array-add '{tile-data={}; tile-type="spacer-tile";}'

To get more spacers, you call the commands several times. To move the spacers around the Dock, just drag them like you would for any app icon. Same in order to remove them, (drag them out of the Dock).
(via macworld)

Tip #3. Get Dashboard widgets on your normal screen

Your favorite Dashboard widgets are usually one keypress away(which you can chose from Settings->Keyboard->Dashboard and Dock) but, if you want to have them on your screen at all times (like they do on Windows), you need to follow these two easy steps:
First, in Terminal.app, type down

defaults write com.apple.dashboard devmode YES

after this, enter the killall Dock command, in order to restart your Dock and acknowledge the changes.
Second, when in Dashboard (mine opens when I press F12), click on your favorite widget and, while dragging it slightly, exit the Dashboard(by pressing the same Dashboard key). Your widget should now appear on the main screen, on top of your usual app windows. In order to hide it, you’ll need to do the same things, but in reverse(that is, keep holding your mouse pressed on the widget, then fire up Dashboard and release the mouse). To disable this neat feature(but why would you?), you’ll run the same command only with devmode NO instead of YES.
(via Lifehacker)

Tip #4. Clean up the contextual menu

After a long time of installing and removing apps, you might get a messed up “Open with..” menu when you right click on a given file; this is because removing an app doesn’t usually clean up the app’s settings, the contextual menu ones in particular. From the same all-mighty Terminal.app you’ll need to run

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user

, press Enter and wait until the command gets finished(might take a while).
On older versions of OSX – 10.3 Panther or 10.4 Tiger, you’ll need to run this one instead

/System/Library/Frameworks/ApplicationServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user

Afterwards, the context menu that you get when you right click(Cmd+click) on those files should be slimmer and more accurate.
(via Maclife).

Tip #5. Boot your Mac the way real hackers do

You can see all the console messages thrown out when your mac is booting up with this simple command, to be typed into the Terminal.app
sudo nvram boot-args="-v"
From now on, when you’re booting your computer, it will write down everything it does, and your user friendly computer will start looking like a Unix hacker’s piece of hardware straight from the Matrix. Guaranteed to get you all kinds of shocked looks from coworkers and classmates. You can also access these messages later by running sudo dmesg in the Terminal.app. To reset it to the default user friendly behavior, all you need to do is run sudo nvram boot-args= in the same Terminal.app.
(via stackexchange)


Similar Posts:

Leave a Reply