Productivity

Effectively Managing Too Many Desktops & Screens on Mac OS X

BToo Many Virtual Desktopseing able to create virtual desktops can increase productivity significantly. With multiple virtual desktops per monitor and people opting to use more displays as technology allows it (MacBook Pro Retina has 2 Thunerbolt and 1 HDMI port, along with a damn nice retina display and the possiblity of daisy-chaining displays and buying external adapters to add even more screens) the complexity of managing so much screen real estate may come at the cost of some productivity.

How Much is Too Much?

Can’t have enough, as long as it’s managed properly, but it also depends on what you do and the specs of your machine. It’s great that Apple is relatively recently allowing you to add more than one external display to your Macbook Pro so easily, they hinder resources by soldering on the amount of RAM in those machines. Terrible. Even with 32 GB of RAM, an iMac and 3 external displays, I didn’t feel like I had enough. Now down to an i5 Macbook Pro Retina with 8 GB of RAM and 3 screens with 4 virtual desktops (1 for each screen, so 12 desktops in total),

Crop Custom Part or as PNG to Desktop with cmd+shift+4 OR cmd+shift+3 for FULL Screenshot

 

<Clippy> OS X? pfft, how can I print full desktop screen prints like in Windows?

<Clippy> What’s the Mac/OS X alternative to the clumsy prnt-scrn (print screen) > paste > MS Paint > save > name and format (oops, saved as useless .bmp again?) > find the file (and possibly resize it if you forgot the first time around) > use file > delete > possibly repeat enter process > or clear clipboard if Windows is feeling sluggish, even if the perceived latency or load is purely psychological. Nothing subjective matters when your brain is subjectively seventeen times slower than “real” time.

Snippet of Desktop Screen Instantly Automatically Saves to BG

Shortcut to Crop Rectangle &  Save PNG to Desktop (or change default location/format)

The shortcuts use any combination of the left and right command/shift keys and either the number 3 (full screenprint) or 4 (crop rectangular area) If you want to workout your fingers, use use leftCommand + leftShift + rightCommand + rightShift + 3 (or 4)). Here’s the result, two screenshots,

In Mac OS X (From Yosemite to Maverick to Snow Leopard to Lion, etc)*, you can crop any part of any screen on any monitor you have running, anytime by using Command + Shift + 4 and check the desktop for a new image. (It helps to have it sorted by Date Modified)

Use Command + Shift + 3

and check the desktop for the new image(s).

Unclutted Your Desktop (Change location and format of stored shots/prints

Soon your desktop will look like this:

changing filename screenshot mac os x yosemite

Change Prefix of Default Screenshot Name Saved to Desktop

defaults write com.apple.screencapture name “___ss” && killall SystemUIServer

Restore name to default “Screen Shot” prefix

defaults write com.apple.screencapture name "Screen Shot" && killall SystemUIServer

WTF is a command or “defaults” anyway? The command line structure and syntax, dissected and easy to visualize.

Change Where Captured Shots Instantly Get Saved In

Instruct, invoke, run, execute, call the defaults cmd, which like most commands isjust the name of an app your Terminal.app (make sure it's open!, use SpotLight) or iTerm or other terminal emu or shell is aware of (technically it exists in your shell's $PATH variable) (usually) should write 3 underscores as a prefix to shots stored in ~/Pictures/Screenshots

Change the Format of the Saved Screenshot to JPG, TIFF, PDF, GIF or default PNG

defaults write com.apple.screencapture type jpg
defaults write com.apple.screencapture type tiff
defaults write com.apple.screencapture type pdf
defaults write com.apple.screencapture type gif
defaults write com.apple.screencapture type png

*pro tip: To avoid repetition in documentation and tutorials, we can put all choices between square [ brackets ] and delimit or separate each choice with a vertical pipe |. The result is [only|one|of|these|words|not|all]. The above 5 calls to default can be abbreviated, ie in their man/documentation pages as:

defaults write com.apple.screencapture type [png|tiff|jpg|pdf|gif]

though typing all of this out would be invalid. You just have to learn that a pipe | is an OR, as you agreed that in literature (or major languages) an ampersand & is an AND. Just remember it.

Read current format Images get Saved As

defaults read com.apple.screencapture

Tip: This is how you read any of these “OS X user defaults”. The Command Line Explained in Detail. To see the documentation, type

man defaults

in the Terminal/iTerm/shell/Bash/Zsh and hit enter to read the manual page. press q or Q to quit and the UP arrow to cycle through the last commands you ran in descending order.

 

Troubleshooting / Screenshot shortcut doesn’t work?

It’s the number 4, not F4, ensure exclusively three keys held. If you can’t locate the images, open up Finder (Command + Space, type finder and press Return when it’s found (usually by the 3rd letter, ‘fin’. Typing nothing else and waiting will drop down mixed results. )

* You can do this in Microsoft Windows 7, Windows 8 or above by using the included SnipperTool.exe (type it into the Start > Search bar, then create a shortcut to it on your Start Bar and/or create a universal shortcut for it. and in Linux and other versions of Mac or Windows (XP, Vista, etc) using third party apps or browser extensions if you’re only interested in grabbing screen captures/crops within your browser.

WTF is a “command” or “passing arguments”? Making Sense of the Command Line

Meow Meow.. Let’s understand how commands, “passing things” to them and “executing” or “running” them works in the terminal/shell by giving hard definitions for what we think we understand a term (pun intended) to mean and how the operating system, shell, scripts, apps, commands, functions and arguments work and how our mental model of them may be (very) skewed.

The following command will replace the prefix for screenshots you automatically capture or crop to your desktop in OS X to “SS” instead of the default “Screen Shot”, just to use as an example. If hit cmd+space type ‘term‘ and wait for ambiguities or hit Return. A terminal window or “shell” where you can type stuff hopefully opens. WTF just happened?

You hit a universal OS X shortcut that runs Mac’s built in open command to execute some binary file (meaning a compiled source file) somewhere in Spotlight.app
Then pass its main function 1 parameter, a string argument with a value of “term”- it does a fuzzy or wildcard search in the index of every single file/directory on your machine (except those you exclude)
defaults write com.apple.screencapture name “SS” && killall SystemUIServer

 

defaults.write(defaults.get('com.apple.screencapture').name('Screen Shot')

Let’s define some terms first

Kernel is the OS itself. The set of “functions” people at Apple, people they contracted and people before them wrote you’re running on the very expensive hardware Apple sold you. The Kernel class is a blueprint or sketch on a napkin, or a form of Plato’s kind, not a tangible thing, except in the following code syntax context, where tangible means a thing you can make instance an of, copy, mutate, read, write-to, etc. A tangible class is an instantiated object, rather than being an abstract class. Thing of a chair class vs an actual chair. Your physical body cannot sit on an abstract chair. It must exist. The “abstract chair” itself cannot just transform to a wooden tangible chair that follows the same rules as your body. It is only an idea, an electrical pattern humans conditioned themselves to agree on so solidly that we can build/import/export/buy/sell/make-shift/DIY/fix and do a million other things with this concept of a chair.

A Tangible class means an object and an abstract object means a class. Kind of. Avoid these terms. They are only here as a koan to break you from your usual stream of consciousness.

`kill` is a function, procedure or method, a “verb” on the concrete object. You can and do have abstract functionality on abstract objects (aka classes),

 

function killall(name) {
   var SIGNAL_TERMINATE = 15;
   Kernel.kill(Kernel.findIdByProccess(name), SIGNAL_TERMINATE);

defaults is an app, probably written in a language called C or in another call =ed Objective-C and compiled. It could also be written in Ruby, Python, Java, Javascript, Lua, or another interpreted language (“script”) that has its “executable” permission set ON. If you see something like |rwx-rw-r defaults| It is simple in that it probably is written to serve a single purpose. The Unix philosophy is “Write something that does one thing and does it well.” “one thing” is relative. Is “email” one thing? Is browsing the web “one thing”? It used to be, but now browsers are extremely complex pieces of architecture that seemingly do different things for different user archtypes.

 

killall SystemUIServer

Hard restart of the SystemUIServer (just an app running in the background. You can also kill it the hard way without a terminal by killing it using killall after defaults succeeds (the && is important)
killall SystemUIServer

 

Terminal/iTerm2/console/shell/Bash/Zsh.. are these synonymous?

Turn Off Animations (Instant Transition) in Mission Control / Exposé on OS X Yosemite, Lion, Mac

mission-control-disable-animations-annoyingThe following will let you turn tweak or completely turn off the animations for Mission Control (still called Expose in some places.) This works for Lion, Snow Leopard, Mountain Lion, Mavericks, Yosemite and probably the next version of OS X. Unfortunately, you can tweak nearly every animation except the slide when switching screens. See the post linked to on the bottom or click here to see how you can bypass OS X’s native Mission Control / Expose window manager and use a sweet 3rd party app called TotalSpaces. See my previous post about using VirtualSpaces to completely turn off/disable swype/slide/transition animation when switching desktops or screens in OS X Mavericks and Yosemite.

 

 

If the gestures listed below don’t work, you will need to enable them (yours may vary depending on your hardware/OS/settings) Thanks to this StackOverflow answer for the command below:

defaults write com.apple.dock expose-animation-duration -int 0 && killall Dock

And to go back to defaults run:

defaults delete com.apple.dock expose-animation-duration && killall Dock

This turns off the annoying animations for Mission Control
(aka Expose) including:

  • Mission Control (swipe up with four fingers or keyboard shortcut)
  • App Exposé (swipe down with four fingers or kb key)
  • Launchpad (pinch with thumb and three fingers, like a crab, or those machines you put a coin in that have a claw which never seems to be able to grip on the toy you’re aiming to get.)
  • Show Desktop (spread thumb and three fingers, opposite of Launchpad gesture ^)

but unfortunately it does nothing for the following animations:

  • Notification center sliding in (2 finger gesture from right edge of trackpad or using kb shortcut)
  • Swiping with 3 fingers on the trackpad to switch between full screen apps
  • Switching desktops (whether using your gesture or dedicated keyboard shortcut per screen/desktop)
  • Switching back <> forth pages in the Safari browser

Reduce window resizing animation speed (I’ve had mediocre results with this):

defaults write -g NSWindowResizeTime -float 0.001

or revert to default:

defaults delete -g NSWindowResizeTime

You’ll have to quit the applications you’re using for this to take effect.

PRO TIP:

It would be nicer if when we made changes using `default`, we somehow kept a log of what we’re doing. Something like ~/.zhistory or ~/.bash_history would be nice. to save these exact commands you’re probably copying and pasting from strangers on the Internet. This is possible with very little knowledge of shell scripting and only a single alias command.

First is the one liner. This will create a temporary file, ask if you want to proceed before blindly applying the new value to the key for `com.apple.dock expose-animation-duration` and then prompt you that Dock is restarting and shows you how many commands (lines) are in that temp file. This is to disable the animation and see this in action on one line:

: ${tmplog:=`mktemp -t ohmytosh.com`} && echo "Writing these files to log $tmplog just in case. Proceed?" && read && echo "defaults write com.apple.dock expose-animation-duration -float 0.1 && killall Dock" >> $tmplog && defaults write com.apple.dock expose-animation-duration -float 0.1 && killall Dock && echo "restarting Dock.. you have `cat $tmplog | wc -l` lines in your temp file"

Here’s the line broken down to make it easier to read:

 

: ${tmplog:=`mktemp -t ohmytosh.com`} && # assign value from `mktemp` to $tmplog if this var is null
echo "Writing these files to log $tmplog just in case. Proceed?" &&
read && # wait for user input (ctrl + C cancels this entire line due to the &&'s)
echo "defaults write com.apple.dock expose-animation-duration -float 0.1 && killall Dock" >> $tmplog && # write command to logfile 
defaults write com.apple.dock expose-animation-duration -float 0.1 && # run the actual command
killall Dock && 
echo "restarting Dock.. you have `cat $tmplog | wc -l` lines in your temp file" # some user feedback. use unset $tmplog, though it will be unset if shell closes.

Upcoming posts: How to use a 3rd party app to avoid viewing the desktop/screen slide animation 50+ times a day and how to put the above into a re-usable shell alias. For now, see how I did it using VirtualDesktops years ago. Nowadays I use TotalSpaces.

If you’re a developer you’ll see some repetition here (violation of Don’t Repeat Yourself, or DRY) but should this be DRY, it’s still a hassle to type out, especially if we’re working a lot with `defaults`. Perhaps we can make this more robust but general enough to use elsewhere, a shell alias perhaps? for next time…

Learn and Begin Using Markdown in 30 Minutes

Markdown, RedCarpet, Markup Language, OS X, Kramdown, Markdown Editor, Viewer, md file, mkd file, .markdown file

Markdown is a very useful tool for note takers, list makers, writers, bloggers, content architects, developers, … Markdown is essentially a common dialect for note taking. It is very close to how most of us take notes of any kind. Applying a standardized format to your static plain text content means your otherwise arbitrary notes, todo lists and essays are now formatted in a ‘markup’ language that is widely adopted and very simple to pick up and begin using right away. This means that machines now recognize elements of your content and can apply styling and other useful features.

Markdown essentially  s l i c e s  a document into a theme or presentation + the actual content. This means that you write your notes exactly the same way, whether you want a concise and structured grocery list or set of tasks for the week, or you’re writing a book that you want to release in 1 or more formats. Your single essay can be put through 3rd party software and automagically rendered as:

  • Printer-friendly HTML readable in any web browser

  • PDF file for distribution and instant accessibility to PDFs are supported

  • .epub or .mobi ebook file for reading on a Kindle or Nook

  • or published as a hardcopy book

Let’s get practical. You’re making a todo list and realize you need to make another section to group very urgent tasks. You want the urgent tasks to stand out, so you add markings and symbols in your writing to convey labeled groups of tasks. In a text document, you may add 2 empty lines to separate a group and put a line (—–) between a group name and it’s items. Done.

It’s simple. It’s plain text—readable by humans because it looks familiar to how most of us “mark up” our notes by indenting, emphasizing, underline something and using * to denote bullets prefixed to items in a list. And it’s readable by software that can now index, make searchable, add styling and accessibility features (i.e., the file is in a common machine language. I can turn it into a .mobi file to read on my Kindle, or to turn it into an audiobook that has features only possible if you can tell which unit of the file is the title and which is the body of text (like, make an audio Table of Contents.)

UPDATE 12/19/2014: I now use Marko.app over Mou. See my post on Marko and WebStorm integration.

 

Markdown, RedCarpet, Markup Language, OS X, Kramdown, Markdown Editor, Viewer, md file, mkd file, .markdown file

Install Mou – The app features a split screen. The left is where you enter your content, and the right is a live preview of your Markup/HTML content styled using one of the themes in the preferences panel. GitHub, Clearness, Tomorrow, Tomorrow+ and other CSS themes are included. While editing, hit command + R to pull up a concise Markdown Language Syntax reference.

Jeff Atwood describes Markdown accurately:

Markdown is a simple little humane markup language based on time-tested plain text conventions from the last 40 years of computing.

Markdown, RedCarpet, Markup Language, OS X, Kramdown, Markdown Editor, Viewer, md file, mkd file, .markdown file

Mou is a free Mac OS X Markdown Viewer and Editor

Dealing With Annoying Slide Animation in Spaces

UPDATE 12/23/2010: The fix below is deprecated. To disable the animation, enter the following in console:

defaults write com.apple.dock workspaces-swoosh-animation-off -bool YES && killall Dock

——————————


This video shows VirtueDesktops running on Snow Leopard.

As somebody who came to Mac from a Linux background, Spaces never impressed me. It’s lacking very fundamental desktop-management features. There’s no workspace selection box in the Dock.

It becomes sluggish over (a very short) time. At first I thought my Mac was slowing down, but then I noticed that it only occurred when I switched spaces. The animation was choppy, and became choppier the longer my Macbook remained on.

You can’t disable the animation. In my search for a way to do this, I came across people complaining about this and requesting it as a feature since at least 2007. This seems like an obvious (and relatively straightforward) feature to implement. You can’t even hack the application to get it working. There are of course ways to mod or ‘hack’ the app itself to alter its behavior, but it doesn’t seem like the concern is worth the massive effort.

The animation makes people sick, it causes a headache, it’s not that impressive after awhile, it’s very confusing and disorienting. When it becomes sluggish, it causes me major irritability.

There are alternative apps you can use. Unfortunately, development stopped for all of these apps as soon as Leopard was released with Spaces. These apps were written for OS X 10.4 (Tiger), and so most don’t even work. Most of the ones that do, suck, but one does one. VirtueDesktops works on Snow Leopard (minus some features) good enough for daily use.

Press cmd+Space to bring up Spotlight, and search for “p spaces” and choose the first option, Expose & Spaces System Preferences. Uncheck “Enable Spaces” – all windows you had on inactive spaces will be merged onto your current space. Now open VirtueDesktop, and you’re pretty much set. Press alt + Tab to select a workspace, and viola – the change is instant. If you’d like to set shortcuts keys to jump directly to a workspace, or just want to check out the existing shortcuts, go to the Bindings page. Here, right click and choose the “Set Workspace ‘Main'” etc for each workspace you have, and double click the trigger column to set a shortcut key. I use ctrl + [1-4] and have my Caps Lock bound to Ctrl.

By default, the app has Main, Mail, Browsing, Code. To change these labels or add/remove workspaces, click the Virtue icon in your status menu and “Inspect Active Desktop” under the “Active Desktop” menu.

Space (not Spaces) – cannot set keys to switch to direct workspace

Virtue – Though it has many bugs, I still prefer using this to using Spaces.
Crashes when you go to inspect -> applications.

You cannot move windows between apps.

The frontmost app is given focus when you switch to that space, as opposed to
focus remaining on whatever app you last clicked.

if you quit, apps on other workspaces are not shown, gotta re-open Virtue to access those workspaces.

Sometimes the desktop will change on its own when you right click a Dock icon and hit “new window”

Virtue Tips:     

use shift + tab to show the desktop selection screen (pager) – this stays open.

use alt + tab to show overlay pager

Display window control crashes (alt + cmd + O)

cubicles – very broken. Does not work. asks you to create a new cubicle and then just slowly redraws the desktop and crashes