Monthly Archives: September 2016

How I’m Using Textedit beyond VI and VIM to edit files from the Mac os terminal

There’s a joke about the Unix editor vi, that goes something like: I’ve been using vi for so long, because I can’t figure out how to get out of it. Vim, in my opinion isn’t any better. I can appreciate the power these editors have, and they’re really fast for those who are comfortable on them, but I think of documents more fluidly than only 1 line at a time. I can use nano if I have to, but I feel most comfortable in an interface at least as developed as something like notepad or Textedit. Enter another way to cheat in the Mac OS terminal.

Before actually doing this, it’s a good idea to change a few settings in Textedit or bad things might happen.

Bring up the preference in Textedit either through the menus or just press Command-comma.
In the new document tab, select the plain text radio button, also make sure that the check spelling as you type, the check grammar with spelling and the correct spelling automatically check boxes are unchecked. You also want the smart quotes and smart dashes options to be unchecked.

On the open and save tab: you may want the display html text as code instead of formatted text checked. You definitely want the add .txt extension to plain text files unchecked, or things will stop working.

Now that we have that all out of the way…

 

alias ted=’open -e $1′

Something so easy you can have it working immediately in a brand new squeaky clean install before you even have your most favorite apps up and running. There are awesome editors out there that can also work with files from the command-line that do way more than Textedit could ever dream of, like TextMate and BBEdit, but this is still a nice fix to keep in the toolbox that requires nothing beyond what OS X provides out of the gate.

Advertisements

How I made reading man pages more efficient for me

I did fairly well in my college Linux class, but never felt comfortable reading man pages. I could do it more or less, but although I would not say man pages were inaccessible, i would say they weren’t terribly efficient for me. Although I grew up on, and still love the command-line I find reading and writing text in a GUI interface much more efficient, especially with copy paste and search commands that work well with screen readers. I work on my MacBook nowadays, and after some googling around, I found several articles on how to import man pages into textedit.

Here’s a function to make it work, it won’t work in an alias.

teman() {
#opens man pages in textedit
man “$1” | col -b | open -f
}

copy that to a file and then at the prompt type
source filename and then you can type teman command, and textedit will open it right up.

The part of the man page that always melts my brain is right at the top of course, the synopsis. Once i can easily arrow past that to the description section and beyond, I can make much more out of man pages and finally they’re a much better learning tool for me.

Command-line stopwatch

Back when I only had 1 iOS device I was wanting to calculate how fast voiceover was reading to me, but the only stopwatch I had was on my iPhone; I had a problem to solve. I probably could have found a GUI program that had a stopwatch as a function but I just wanted something really simple, and the command-line is my friend.

 

I knew about a timer command in 4DOS and Take Command 32 made by JP Soft  that I liked to use back in the day, and after some googling found unix linux and OS X had a similar time command, then I wondered how I could suspend the terminal session so time would be timing the pause, cat with no input was the answer.

time cat
and press enter.  The stopwatch will start, but you won’t get any ,  feedback, not even a prompt, but it will keep track for you intel control-c is pressed. Then you will get the timed result.  .

real 0m4.457s
user 0m0.002s
sys 0m0.004s

The top line beginning real is the elapsed time, that’s what you want.

The second line is , the time consumed by system overhead,

and the third line tells the time used to execute utility to the standard error stream. rarely will lines 2 and 3 matter but at least they’re there if you ever need them.