2

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.

Gareth
  • 19,080
cwd
  • 18,788
  • 43
  • 123
  • 162

2 Answers2

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
  • 111,893
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
  • 248