Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Mac OSX Finder to preview programming text files that don't have .txt or .text extension?

Tags:

macos

Programming obviously involves lots of text file usage. You often want to see what you did somewhere else in some other program, without loading up that whole program into your current IDE of choice.

If I copy a text file from say fred.cpp to fred.cpp.text, I can view the contents of the file from the Finder's preview. But I don't want to have copy or rename all my development files.

In a 2003 (!) post on MacOSHints, there is an instruction to do this

find . -name *.xml -exec SetFile -t TEXT {} ;

(in that case, for *.xml files), but this didn't work for me due to issues with the exec command. But in any case, surely there's a better way to do it from the GUI?

Either way though: a command-line or a GUI solution would be great, thanks!

like image 775
Phil Ryan Avatar asked Jun 03 '14 02:06

Phil Ryan


People also ask

What can you do with preview on a Mac?

While it's primary purpose offers you a quick and easy way to see various documents, it has several pretty cool editing and markup features you may not even be know are there. Preview is the default app for viewing images and PDF files on your Mac. So, any time you double-click on, or otherwise launch, one of those files, it'll open in Preview.

How to view photos and PDFs in preview on Mac?

How to view photos and PDFs in Preview on Mac 1 Right/Control - click on the file you want to open. 2 Hover on Open With… 3 Click Preview

How do I open a text file in preview?

Preview only works with PDF files and some image files (png, jpg, gif, tiff, bmp) so you won't be able to open a text file on Preview. To open your info.txt file from terminal you need to choose an application that can open text files, like TextEdit or any other text editor. You also could use open -e file, to open any file using TextEdit.

How do I search for words in a PDF on Mac?

You can open a PDF or other document in Preview, then search for a word or any set of characters. In the Preview app on your Mac, open a PDF. In the Preview toolbar, type a word or phrase in the search field (you may need to resize the window to see it).


2 Answers

2 years late but you can use

https://github.com/anthonygelibert/QLColorCode

install via brew cask

brew cask install qlcolorcode

or

brew install --cask qlcolorcode

(if you have a newer brew.)

for more nice usages of the quicklook, check this repo

https://github.com/sindresorhus/quick-look-plugins

like image 69
Jimmar Avatar answered Oct 05 '22 08:10

Jimmar


There is the Textmate QuickLook plugin which only works with Textmate running.

Pro: Syntax Highlighting
Contra: Only with (non-free) Textmate running


Alternatively: QLStephen

QLStephen is an Apple OSX QuickLook plugin that lets you view plain text files without a file extension.

But it works for all plain text files (even with extension).

Pro: Stable and free
Contra: No syntax highlighting

like image 25
2called-chaos Avatar answered Oct 05 '22 07:10

2called-chaos