Category Archives: Tech Tidbits

MarkDown QuickLook MacOS

Donald G. McGahan
September 14, 2017

This post is about getting MacOS to preview my markdown file when I have the file highlighted in the finder and hit the spacebar. This is called quicklook in MacOS terminology. I need to apply this over several machines so here is why and what I’ve done.

My filesystem is starting to become quite populated with plane text files where I use a flavor of  John Gruber’s MarkDown to enhance the utility of what final display format I intend for the content to be delivered in.

I have more than one MacOS application that I have been using as crutches when creating or modifying these text files with MarkDown. One is Byword and the other is Fletcher Penney’s  MultiMarkDown Composer.

These files are truly plane text and the file extension might just be “.txt” and indeed this works just fine. However, if given a unique extension the OS can be instructed to view and open the text files that I have sprinkled with markdown in one of my helper applications.

The frustration I was having is that I had files with extensions including  md, mmd, and markdown. John Gruber and Fletcher Penney favor markdown. I see the advantages of using markdown as the extension and will likely adopt that moving forward.

The issue with quicklook not rendering a, quicklook, for the different markdown extensions I am using. While there may be a more elegant way to address this what I found is a GitHub repository by Phil Toland for QLMarkdown which I applied using homebrew at the MacOS Terminal app.

$ brew cask install qlmarkdown

Audio file from text with OSX say

A say example:

Using terminal navigate to the directory where the source file is at.

say -v Ava -o "audio_file_created.aiff" -f "file_to_read.txt"

-f tells the program to read the file following in parenthesis
-o tells the program the output file to record to.
-v is the voice to use

Personally I use another app to convert to mp3 since that is small and fairly ubiquitous.

To use wave as the output (-o) navigate to the source directory. Then add –data-format=LEF32@8000 after the output file.

 say -v Ava -f "Findings_about_Research-R2_JGnKS.txt" -o Findings_about_Research-R2_JGnKS.wav --data-format=LEF32@8000

This sounds lousy though. I prefer to use Quicktime 7 and convert.

More can be learned from a web search, but this is a note to self.

Talk Back prose or prose poetry

Talk Back prose or prose poetry

SpeechnDictationIconWant to have a second read of something you have written?
Kind of a dispassionate editor type of read?
Here is a way to make your writing read more polished.

When I write, I have an inner dialog which I put to words on paper, well not so much paper as into a text editor or word processor nowadays. I notice that when someone else would read it out-loud it frequently does not carry the same cadence and emphasis that it did in my inner dialog.

I have noted these discontinuities and questionable meanings with others writings also. These are readily identified in others writing wether I read there work out-loud or silently. I often think, “What are they trying to say?” when reading new scientists writings, and especially with students submissions.

With student mentees drafts, I would expect some rough spots like these, but they happen overly often, and go unidentified by the author, lingering over many drafts (that is when I can get them to submit more than one draft :-). So, I recognize that it is hard to track down discontinuities and questionable meanings and fix them: especially with the very compressed turnaround time we work with for todays communications.

I have found that if I use a text to speech feature on my Apple OSX computer I can fix many of these in my own writing. I have long been using text to speech as a tool with face to face editing sessions with student mentees and they have very positive responses.

How to enable text to speech.

OSX computer — interpret OSX to mean a Mac

With an OSX computer it is easy to have the computer speak selected text. Just go to “System Preferences” and choose the “Dictation and Speech” icon, choose the “Text to Speech” button and check the “Speak selected text when the key is pressed box.” The default is Option+Esc key combination and that has worked fine for me — your mileage may vary — but you may choose another key combination. Just select some text, and Option+Esc key combination.

iPad

On the iPad it is only slightly more work to turn on this great feature.

Launch “Settings” (the icon of a gear) and choose “General” then choose “Accessibility” and toggle “Speak Selection” to on. I the “Speak Selection” dialog window the voice used and the “SPEAKING RATE” can be adjusted. I like the “Highlight Words” being set to on but you can turn it off. With “Speak Selection” set to on, when text is highlighted “Speak” is an option on the popup dialog. Happy Days. (This works for the iPhone as well.)

Windows 7

Open the “Ease of Access Center” window by pressing the Windows key + U, or by clicking the “Start” button, choose “Control Panel,” then choose “Ease of Access,” then choose “Ease of Access Center.” Under the “Quick access to common tools” header click ‘Start Narrator‘, or press Alt + N. (This will start Narrator for current use and to make Narrator start automatically when you log in, with the “Ease of Access Center” window open. Under the “Explore all settings” header, click on “Use the computer without a display,” or press Tab until it is highlighted and then press Enter.

Keyboard shortcuts in Windows 7 Narrator

To read text from a screen, use the following shortcuts when Narrator is running.

    • Insert + F3 – Read the current character.
    • Insert + F4 – Read the current word.
    • Insert + F5 – Read the current line.
    • Insert + F6 – Read the current paragraph.
    • Insert + F7 – Read the current page.
    • Insert + F8 – Read the current document.

There you go. Clear as mud. Lots of key combinations to remember.

Windows 8

In Windows 8 Microsoft has moved in the direction of complexity as there are different ways to get Narrator turned on depending upon the device.

  • On the sign-in screen, press the “Windows logo key+U” or click the “Ease of access” button in the lower-left corner, and then choose “Narrator.”
  • On a keyboard, press the “Windows logo key+Enter.”
  • On a touch-only device, hold down the “Windows logo button and press the “Volume Up” button.

I like this description the best (probably because I have used Windows since before there was Windows 🙂

Settings > Control Panel > Ease of Access > Speech Recognition

 Summary

Most modern devices have text to speech capabilities so the device is not the issue. The iPad is best at being used to consume and digest information, with only modest “creating and authorship” capabilities. This lends it well suited to using it as a tool to assess the readability of ones one work.

Add a little color to Macs Terminal

I added a little color to Mac Terminal.

Here is how.

To edit the file(s) use:

nano ~/.bash_profile
nano ~/.bashrc

If no .bash_profile and .bashrc the do the following to create them.

In the Terminal enter:

touch ~/.bash_profile
touch ~/.bashrc

Then you can use nano to edit the files.

Add the following to the .bash_profile

export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad

To immediately enable any changes in the file .bash_profile use source:

source ~/.bash_profile

This will assign a new set of colors to the terminal text.

Screen Captures using a Mac

OSX Preview and Grab application icon images
OSX Preview and Grab application icon images

Screen Captures using a Mac

Windows users often tell me about the Sangit application available from TechSmith. This program is available for OSX also, but is an extra expense.

The synopses is that an application/program to capture screenshots is built into the OSX operating system. Using Sangit does not preclude using Grab, and visa versa.

Currently I am using the Mavericks OS (10.9) but much of this works in previous versions of OSX.

If your the non-technical type, jump to the “Creating a Screen Capture image from within Preview” section below.

Grab the app

I have been using the great application “Grab” for quite some time. Grab is found using the Finder in Applications –> Utilities and when using the Launchpad in/on the Dock in Other. The icon is a pair of scissors overlaying a square depiction of a screen.

Four options to capture screen content exist once the Grab application is started: SelectionWindowScreen, and Timed Screen. And you choose between these from the Capture pulldown menu.

Key Combinations to “Grab” Screen Captures

You can place the Grab icon in the Dock if easy access, but invoking the program from the icon (via the graphical user interface [GUI]) is not the only way to use this handy app. You can also use key combinations.

Several options for screen capture are possible. One thing the new user of this app should probably be aware of is that images captured using the keyboard shortcuts are stored on the desktop by default. This can be changed, and the “how-to” is below. First, however, how to use those keystroke keyboard shortcuts! Here they are:
  • CMD+Shift+3 will capture the entire screen and save it as a file.
  • CMD+CTRL+Shift+3 will capture the entire screen and copy to the clipboard.
  • CMD+Shift+4 will capture an area that you select and save it as a file.
  • CMD+CTRL+Shift+4 will capture an area that you select and copy it to the clipboard.
  • CMD+Shift+4 then space will capture a full window, menu, desktop icon or the menu bar with drop shadows and save as a file.
  • CMD+CTRL+Shift+4 then space will capture a full window, menu, desktop icon, or the menu bar with drop shadows and copy to the clipboard.
  • Holding down the SPACE key after you start drawing an area will allow you to reposition it.
  • Holding down OPTION right after you start drawing an area will allow you to adjust the width and height of the selected area.
  • Hit ESC while capturing an area or window to exit the capture mode.
Todays average personal computer user is so pampered and unsophisticated (yes that sounds harsh, but it is the truth) that they don’t realize that most apps and programs have some very powerful and handy keyboard shortcuts. These save tons of time in the long run with an investment of a little memorization of the keyboard shortcuts.

Change “save to” locations of Grab key combinations

Alright, back to the issue of the keyboard shortcut invoking of the app’s saving to the desktop. I like to keep my desktop as uncluttered as possible. It is hard to do, but one can always try :-). You can easily change the location using the following terminal commands.
defaults write com.apple.screencapture location ~/Downloads

Then again in the terminal

killall SystemUIServer

This will change the default location to the Downloads folder. Another location can be chosen if desired.

The pictures are saved as tiff format. Use Preview to open and then save them in an alternative format if desired.

 Creating a Screen Capture image from within Preview

You can easily just do this all from within Preview.

  • Start Preview using one of the methods below
    • Finder>Applications>Preview
    • Click the Preview Icon in your Dock
    • Search Preview in Spotlight
  • At the top of your screen, click on File in the drop down menu.
  • At the bottom of the drop down menu, hover your mouse over the text ‘Take Screen Shot”
  • You will see a choice of:
  • From selection
  • From window
  • From entire screen

Preview has tools to annotate the screen capture picture.

Word Superscript and Subscript Find and Replace

Did you know that you can do a find for something like H2O and replace it with H2O, m3 with m3, and kg-1 with kg1?

Word’s Find and Replace to the rescue… In this example, I’ll use H2O but the same technique applies for anything similar.

  1. Change one of the incorrect instances of H2SO4 to the correct formatting  (H2SO4).
  2. Copy the correct format (H2SO4) to the clipboard (select all the text and then press Ctrl+C).
  3. Open Word’s Find and Replace (Ctrl+H).
  4. In the Find what field, type H2O (the incorrect format).
  5. In the Replace with field, type ^c (that’s a Shift+6 for the caret [^] character and a lower case ‘c‘ — the ‘c’ MUST be lower case).
  6. Click Replace All.

Keep it Together

One of the annoying things about word processors is actually a strength. Word wrap. Think about it. You don’t have to: usually.

Word processors do an amazing task of wrapping text to fit within the lines, margins really, and they adapt when you change the margins. Brilliant really.

But, what if you do not want a hyphenated technical term to break at the end of the line? Worse yet are technical values with units that break between the units. Very difficult to read.

Following, I jot some quick ways to keep them –hyphen (em dash), spacebar break, underscores– from breaking at the end of the line.

Drumroll please….

For Microsoft Powerpoint hold down the Ctrl and Shift + keys

Microsoft Word version 15 for Mac try command + shift + keys

Apple Pages try option + keys

You do know that you are not generally supposed to put a dash between a number and the unit, right?

Wrong: 12-cm

Right: 12 cm

use a non-breaking space between the value and the units.

If the value and units are a complex adjective preceding a noun then the hyphen is called for. For more about hyphen grammar guidelines see the GrammarBook blog by Jane Straus at http://data.grammarbook.com/blog/numbers/hyphens-with-numbers/

Converting text formats with OS X terminal

It is handy to be able to convert from one text format to another.

It is probably very common that the ‘right tool for the job’ is not often applied with it comes to digital files. This is likely because of impatience and being unfamiliar with the proper tool.

I have seen several instances where someone will load up a word processor, waiting several seconds for it to get to a ready state, and then fuss with opening menu after menu to try and accomplish converting the file.

This seems inefficient and cumbersome.

With the OS X operating system it is a snap to accomplish this type of task using a command line tool called ‘textutil’.

This ‘textutil’ can write out as txt, html, rtf, rtfd, doc, docx, wordml, odt, or webarchive.

Personally I have many times written a web page html and want to make a rtf document.

Open the Terminal (an easy way is to begin to type terminal in Spotlight) and enter:

textutil -convert FORMAT path-to-the-original-document

Replace FORMAT with txt, html, rtf, rtfd, doc, docx, wordml, odt, or webarchive.

This will place the converted file in the same directory as the original  file.

Viewing hidden files in OSX Finder

To view hidden files in Finder go to the Spotlight and enter Terminal. The Terminal app should be the first choice.

Start Terminal and at the command prompt enter:

defaults write com.apple.finder AppleShowAllFiles -boolean true
killall Finder

Now when you return to Finder the lighter grey file names are files that are normally hidden and are now visible. Generally, it is not prudent to delete these files unless you have investigated the implications of deleting these files.

The difficulty now is that thereafter the hidden files will show in the Finder. To make the files hidden to the finder again, enter the following at the command prompt in Terminal:

defaults delete com.apple.finder AppleShowAllFiles
killall Finder

While this is a bit techie, I do have need of this from time to time. Mostly, in user mode, we don’t want to be bothered with seeing these files.

However, sometimes I am communicating with users who live in the Microsoft Windows Operating System world and they are confused when they see hidden files in shared folders. This is especially true of some of the shared cloud folders for collaborations. It those cases, I can sometimes simple state that the files preceded by a ‘dot’ are to be left alone.

Sometimes, I must go further to satisfy their curiosity, or to convince them to leave those files alone, and then I explain that the prepending ‘dot’ hides the files in the BSD, UNIX, and LINIX operating systems. Generally, I don’t have to go farther than that, but occasionally, it helps to point out specific examples and to name a file that they are seeing in there ‘explorer’ that is/are to be left alone.

Perhaps the quickest way for me to see the hidden files to point out an existing example file they are seeing, is to enter the Terminal app and list the folder in question using the command

[Machine_Name]:[Path_to_Folder] [User_Name]$ ls -al

Where I have navigated to the folder [Path_to_Folder] in question.

I have found that when we are looking at the screen of my Mac together, the Windows user can be severely intimidated by the command line. They seem to simply stop processing anything that is said when the terminal is open. Not their fault! They might have never seen the power and majesty of the way computers really work (and they probably never saw the first Tron movie either).

Therefore, the above method of revealing the hidden files in the Mac OSX Finder has, in my experience, been a ‘less jarring’ experience for them.
Though you might have to envok a little ‘wizard of OZ “pay no attention to the man behind the curtain” while you run the command to reveal the hidden files. (Hint: you can have a stickie that has the command at the ready to paste in at the command line)

Do you have a favorite Apple Mac OS X terminal command?