How can I type text from a file on Mac OS X?

2

1

I have text in ~/myfile.txt and I'd like to be able to "type" it into the current application, which will probably be TextMate or Terminal

I'd like to see if I can have this happen without using the clipboard. Quicksilver has a cool action called "Type Text", but it works with the current selection and doesn't pull the text from a file:

enter image description here

I tried using Quicksilver's "save command to file" option, which would save this as "Type My Text.qscommand", which I could then modify on the fly and replace the "text" that was inside of this file, and my thinking was to have that run which would type the text, but apparently even without modifying the file this command does not work if it is saved to a file and executed.

enter image description here

So my other thoughts - possibly use

  • Typinator
  • Textexpander
  • Applescript
  • maybe some other macro program?

to set up a way that I can type text from a file (~/myfile.txt) into the current application, but I'm not sure how to go about doing that.

cwd

Posted 2012-01-14T17:44:20.247

Reputation: 13 508

Try Alfred instead of Quicksilver! Has a nicer UI and better search ;) – Will – 2013-02-13T22:11:21.160

Answers

0

Here's something that works if your text is only one line : Select your text file in the first pane, right arrow in it, then choose Paste from the action pane.

I think you need the Text Manipulation plugin to be able to right-arrow into text files.

tiennou

Posted 2012-01-14T17:44:20.247

Reputation: 228

0

You can do this using Automator. Select to create a Service that receives no input in any application whose Output replaces selected text (you don't actually need a text selection for this to work).

  • Add a Get Specified Finder Items action, and add myfile.txt to its list. You could alternatively hardcode the file path below and skip this step.

  • Then, add a Run Shell Script action, and pass input as arguments. Replace the default echo command by cat.

This will cause the file contents to be the output of your service, which will be added to the current document you're editing.

enter image description here


TextMate works as expected.

Terminal ignores a single trailing newline when inserting the text, i.e. you need two if you want to directly execute the last line as a command.

Daniel Beck

Posted 2012-01-14T17:44:20.247

Reputation: 98 421

cool. will give it a try. btw are you a quicksilver user? – cwd – 2012-01-14T22:23:11.837

@cwd launchbar, since quicksilver messed up its index once too often. I use it for nothing fancy though, just launching, spotlight and calculator. – Daniel Beck – 2012-01-14T22:46:27.703

maybe give it another try since they have a new version and you're a power user... – cwd – 2012-01-15T04:35:49.413

@cwd Did it work for you? – Daniel Beck – 2012-01-20T19:55:05.880

still exploring. don't worry i will get around to accepting it :) – cwd – 2012-01-20T20:03:41.263

@cwd Was just wondering since there's no other answers and no feedback from you. You're usually pretty quick in responding and/or accepting. – Daniel Beck – 2012-01-20T20:04:42.213