Speaking from the Command Line

One of eight tips from [Mitchell Cohen][] points out that you can not only use Mac OS X’s built-in *Text to Speech* engine from the command line (`say “some text”`), but, even more usefully, you can save the results to an audio file–again, all from the command line:

say -f mytext.txt -o myaudio.aiff

[Mitchell Cohen]: http://www.mitchchn.me/2014/os-x-terminal/

Papers (Reference Manager Software)

I am just about done with moving a wide variety of research materials into the research management application [Papers][]. After trying to embrace Zotero for several years and never finding myself using it, and I recently found that the Application Support directory for Zotero had grown to an astonishing 2.82 GB. By comparison, my new Papers support directory, which has more material in it, weighs in at 268 MB. Quite a difference. I by no means mean to diminish Zotero: it is a fine, community-sourced app that is trying to be many things for many people. But its interface was always a limitation for me, and it has limited support for writing applications outside of Microsoft Word. (It’s RTF scan functionality never worked for me.)

I chose Papers over Sente for a couple of reasons:

1. Papers is cross-platform, and, like my writing application of choice, [Scrivener][], appears to be a Mac app that developed such a fierce following that demand for a Windows version made it a compelling option. By being cross-platform, like Scrivener and like Lightroom, my workflow is not tied to any particular platform, only to a small collection of developers who have shown their interest in providing excellent software and support for their paying customers — and I don’t mind paying at all for good work, and both these apps represent that, I think.
2. While I respect Sente’s move to address problems its users were having with DropBox syncing, forcing me as a user to sign up for their service and face an additional charge is an additional cost which I resent. If there were a clear way to support a local syncing infrastructure, I might have explored Sente more. I certainly found their dual note/quote stream very compelling, and I will urge the developers of Papers, at some point, to pursue that more. (For those interested in the dollar amounts: Sente’s free account is limited to 100 references per library — libraries are unlimited, so I guess one could simply produce an infinite number of libraries in hopes of never paying. Each library is limited to 250MB in attachments. After that, you need to pay $50, $30 for academics, for an expanded library.)

I was very close to purchasing Sente, for the dual note-stream of quotations and notations mentioned above, but I balked at the added cost of syncing. Papers’ syncing requires that the two devices be on the same network, but here’s hoping that its developers eventually realize that working with the DropBox library is preferable for some users. (I understand, however, that that could lead some users to have both apps open at the same time and make conflicting changes to the library. If the Mac app handles the syncing with the iOS app directly, this can be avoided.)

Why a reference manager? So I can do away with all the various `/sources` directories I have created in every single project directory for the last two decades. Doing so and working with sometimes overlapping projects meant that I either moved sources around or created duplicates — and if you have ever annotated one copy of a PDF and then lost that copy, with all your really good notes and highlights, you know it’s the same pain as loaning out a favorite book with all your marginalia and have it never come back: some part of your long-term memory has just been lost.

I already feel saner with having a central location in Papers. I haven’t used the application long enough to warrant the trust I currently feel, and I will certainly report any issues or problems I come across. Perhaps by summer’s end I will be able to give a better evaluation of the app’s utility and fidelity.

[Papers]: http://www.papersapp.com
[Scrivener]: http://literatureandlatte.com

Rebuild Launch Services!

The actual title of this post should probably be something like *If the **Open with…** contextual menu has duplicate entries in it, then do this.” But that seemed overly long. The problem with mentioning *Launch Services* is that most people don’t know it’s there and that it’s responsible for such things. Here’s a better way to do this, if you get a contextual menu in the Finder which looks like this:

Screen Shot 2013-04-18 at 08.33.06

And you want to do something about it,
and you want to attend to the fix yourself,
and you aren’t afraid of the terminal…

*Then*, you can do this: open up a terminal window (look in the Utilities folder inside the Applications folder [CMD + SHIFT + U]), and paste the following code in the command line:

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

It’s long, but it needs to be just that way. Press return. Wait a second or two for the command to complete. You will know it’s done when the prompt comes back, indicating that it’s ready for another command.

*Then* simply re-launch the Finder. (Under the **Apple** menu, go to **Force Quit…** and you will see *Finder* listed as one of the apps that can be quit, or in the Finder’s case, re-launched.) You do not, as other instructions around the web indicate, need to log out and back in, nor do you need to re-start your machine. Running the command above and re-launching the Finder is all you need to do.

Mac OS LSM Reference

Apple’s `LatentSemanticMapping.h` documentation is [here](http://developer.apple.com/library/mac/#documentation/LatentSemanticMapping/Reference/LatentSemanticMapping_header_reference/Reference/reference.html#//apple_ref/doc/uid/TP40011480).

And [here](http://pypi.python.org/pypi/pyobjc-framework-LatentSemanticMapping/2.3) is the Python Package Index page for the `pyobjc` framework to access the Mac OS LSM … which makes it very clear that I’m not ready to do anything with it. (It notes that Apple’s documentation is sparse, at best, and that you’ll need to be comfortable with `pyobjc`.)

One other possible culprit for the `sandboxd` items showing up in my Mac’s console: the System Management Controller. Here are [directions for resetting the SMC](http://support.apple.com/kb/HT3964?viewlocale=en_US&locale=en_US).

Lion Diskmaker

[Lion Diskmaker](http://blog.gete.net/lion-diskmaker-us/) also works for Mountain Lion: “Lion Disk Maker is an application programmed with AppleScript that you can use with Mac OS X 10.6, 10.7 and OS X 10.8 to burn a DVD or build a bootable drive from Mac OS X Lion or OS X Mountain Lion Installation program. As soon as you launch the application, it tries to find the OS X Install program with Spotlight. Then, it proposes to build a DVD or create a bootable install disk.”

I’ve heard lots of good things about it and it does make it possible to do a clean install of the OS, something I am considering because of [the rise of kernel_task](http://arstechnica.com/civis/viewtopic.php?f=19&t=1179717).

MacJournal versus Day One

There are two things that Day One currently has going for it that MacJournal needs:

1. First, syncing through DropBox is dead easy, and, more importantly that means syncing **all** your devices, including iOS devices.

2. Day One offers a minimalist user interface for writing that doesn’t require one to go into full screen mode.

I know full screen is all the rage, but sometimes I want nothing more than a neatly-styled text box to type into that will then expand into a fuller UI if I want it. Scrivener almost gets this right except it doesn’t know how to adjust its width accordingly — this may be a function of Mac OS options than the app itself. I really like apps that grow and shrink their size modally, e.g. iTunes.

**UPDATE** (July 2012): I have returned to being a loyal user of MacJournal, which will shortly be beta testing syncing options, including through DropBox. My return is precipitated on a few things:

1. The developer of MacJournal is amazingly friendly and helpful and has been for years. I contacted the developer of Day One once, and I thought very respectfully, and his response was, well, to use an old-fashioned word, *churlish*. (It’s more polite than the first word that came to mind.)
2. MacJournal already offers almost all the functionality I want: tags, the ability to post something from the app to a variety of blogging platforms, the ability to include graphics in posts. It’s not perfect in this regard, but it’s got a lot packed in it.
3. I still prefer the UIs of the two Day One apps: they really are lovely, and I hope MacJournal’s developer has the chance to try some things out. It may be that his user base largely prefers things as they are — and since I am only one voice in a larger market, I have to respect that.

Make Your Library Visible in Mac OS X

I understand Apple’s need to make sure user’s don’t shoot themselves in their feet by mucking about where they don’t belong, but it’s too often the case that I actually need to add something in user library, `~/Library`, and having to go to the Finder’s **Go** menu while holding down **Option** is a pain. My answer? Return things to the way they were with the Library always being visible:

chflags nohidden ~/Library

Your thanks are noted.

Adjusting Your PATH

In a previous post on getting NLTK up and running on Mac OS X, I mentioned that once you install a separate version of Python, with which to play and to work, you need to adjust your PATH. Doing so, directs your computer to use the newly-installed version over the version that comes with Mac OS X. This kind of direction, of indicating to the operating system which programs to use, is known as adjusting the PATH.

When you run a command from a UNIX or UNIX-like shell, the shell looks for the executable file using the directories listed in your PATH variable as a map. Your PATH variables are really just a part of your shell profile. Nothing more than one part of a larger list. For the record, my .bash_profile file looks like this:

% more .bash_profile
# Bash Profile

    PS1='\W % '
    PS2='$ '

# MacPorts
# export PATH=/opt/local/bin:/opt/local/sbin:$PATH

# Emacs
alias emacs='/usr/local/Cellar/emacs/23.3b/bin/emacs'

alias Learn='cd Dropbox/personal/programming/learn'
alias Research='cd Dropbox/research'

    # Set architecture flags
    export ARCHFLAGS="-arch x86_64"

I’ve included the more command that I typed to look at my .bash_profile, but apart from that this is the entire file. Reading it, you’ll see:

  • That I’m goofy enough to name the file: note that this line and everything else that isn’t something I want the shell to act upon is “commented out” with a hash, #, at the beginning of the line.
  • Next I have the customization for how I prefer my prompt to look: here it’s simply the current working directory.
  • Next is my obsolete MacPorts variable information. (I should probably get rid of that.)
  • Then there’s a list of PATH variables to enable the system to find things I have installed using Homebrew, including Python, as described in my previous post.
  • Then there’s a few more variables for apps I use.
  • And finally the aliases I use for directories in which I often work and don’t feel like re-navigating the file system.

That’s it. That’s all there is to PATH. If you are using Mac OS X, it’s a good bet that Bash is the default shell and that the file you need to edit is .bash_profile. The best way to do that, in all honesty, is to use a simple CLI (command line interface) editor like vi — there’s also nano and joe and emacs to be sure. Because of the dot at the beginning of its name, .bash_profile is not normally viewable in the Finder. You can search and find the terminal command that changes that, but, to be honest, there are an awful lot of little hidden files that I just don’t want to have to deal with on a daily basis. When I want to work with hidden files, I can find them through ls -a (list –all files) and then edit them while in the terminal.

UNIX Tutorials for Mac OS X

You have to use the [Internet Wayback machine](http://web.archive.org/web/20090217181656/http://www.osxfaq.com/Tutorials/LearningCenter/) to get to them now, but they are still available and they are still useful.

There’s an App for That (That You Made)

When I am doing just about any kind of reading or film watching, I find that having my iPhone or iPad handy is really about having Wikipedia handy.

(If you haven’t donated yet, you should. Do it now. Give them $5. $10. It’s easy. I’ll wait. Really. No, really, I’ll wait. Go donate something.)

Occasionally I have my MacBook with me, and I actually find myself looking for the Wikipedia app that’s on my phone and tablet. Crazy, yes, but when you want to look something up quickly, it really is nice to go straight to where you want to go.

With that in mind, I would like to thank Andy Ihnatko for point out how easy it is to create desktop web apps in the latest iteration of the Mac OS, Lion. How easy?

This easy:

1. Launch Automator.

2. Click on create a new App.

3. Find and drag the “Get Specified URLs” action into your workflow. (Just type the name into the search box until Automator finds it for you.)

4., Paste in the URL of the site you want to view.

5. Find and drag the “Website Popup” action into the workflow. Choose a size for the window.

6. Save. Done.

Here is what you get:

Wikipedia app in the dock

And it pops up this:

Wikipedia on the Desktop

Audiobooks in iTunes

> Well, first you’ll need to convert the mp3s to AAC (M4A) – yes I know transcoding between lossy formats is bad but I recently converted from MP3 to M4A for just this purpose (using the Spoken Podcast option in iTunes > Preferences > Advanced > Importing) and was impressed with the quality. Once you’ve put it onto that setting I just mentioned, select and then Control-Click the mp3s in your iTunes library and then Convert to AAC.
> Once that’s finished (it may take some time) you need to do a few more things to make iTunes recognise the files as audio book content. First, select the newly-converted AAC (M4A) files and Get Info. Under Options, select ‘Remember playback position’ and ‘Skip when Shuffling’. Then use the Reveal in Finder command after ok’ing the Get Info dialog and – here’s the crappy part – manually rename all the extensions of the .m4a files to .m4b. No, there’s no quick way to do it, each one, manually. Makes you sick doesn’t it. Once that’s done, delete the old AAC (M4A) converts from your iTunes library and then add the .m4b files you just renamed to the library and voila.
> Apple sure make things easy. Of course you could just use the ‘Skip when shuffling’ option but then it wouldn’t be in the Audiobooks menu, and if you’re like me you want Audiobooks to be in the goddamn Audiobooks menu!

Login to Console

>console still works for me in 10.5.2; it’s just that there’s a log message printed over the “login:” prompt so you can’t see it (but it is there). For those who don’t know about `>console`, basically at the login window you enter `>console` as the username, with no password, and then loginwindow will exit and you get a text console. If your login window is set to show a list of users, hit the up or down arrow key to select an item in the list and then press option-shift-return. Then you can type in `>console`. At the login prompt (obscured by the log messages), type your username (short version), hit **Return**, then type your password and hit **Return** again.

Edit in Textmate

Remove old version:

rm ~/Library/InputManagers/Edit\ in\ TextMate

Create InputManagers folder:

sudo mkdir /Library/InputManagers

Copy the input manager to /Library:

sudo cp -pR /Applications/TextMate.app/Contents/Resources/Edit\ in\ TextMate/

Ensure everything is owned by root:

sudo chown -R root:admin /Library/InputManagers