1

How do I make C files appear in the browser's window when I navigate to them on a web page? (I use Iceweasel which should be identical to Firefox.)

I don't want to download the file, not open it in Emacs, etc., I just want to view it like any other page.

For example, Perl files (.pl) are OK.

But, C files (.c) have an option line in Preferences -> Applications. Here, I can chose what to do - download them, open in Emacs, etc., but how do I chose to just view them? (Tried to pick Iceweasel - didn't work.)

Ironic thing is, I think "view in browser" is default (as there is no option for Perl files) - so if I could somehow remove the option line for C, that's worth a shot.

1 Answers1

1

Thank you. I have wanted to do this for ages but never get around to finding a solution. Your question forced me to :).

Solution 1

Use the Open in Browser extension. This works perfectly well but adds some whitespace to the left of each line in the source code file.

Solution 2

Change all extensions to .txt. I often build websites for sharing my data with my collaborators. Since I work on Linux, I often have random extenions that are only informative to me. Things like file1.out or file1.res or file1.thisbetterwork or whatever. I cannot tell them they need to install an extension, so my webpage links to copies of the relevant files with txt extensions that I have made in my server's directory:

$ for i in *.c ; do cp $i /var/www/mysite/sources/$i".txt"; done

This assumes your file names are sane, containing no spaces or other strange characters. Look at my answer here for tips on how to modify it to deal with stranger file names.


This bug offers some background. We are not alone.

terdon
  • 54,564