9

I have a bunch of CLI-only computers (I have not bothered to set up a GUI yet). I'm comfortable enough in the CLI to not NEED a GUI for most things. However, as a student, turning in Plain-Text documents really doesn't cut it.

Is there a way to edit Rich Text Format (.rtf) files from a CLI without popping into a GUI? I'd just need justification (Right, Left, Center), bolding, italics, and a bit of fonts (Sometimes I need to pad my Times New Roman font to a full 13 points to reach a page limit).

Heck, it could all be done manually in HTML, with a web-browser engine, and saving to the interesting .rtf font symbols instead of HTML tags.

Anybody know a way for me to do this?

5 Answers 5

9

I presume you want to hand-in a nicely formatted document, and the use of RTF your proposed solution. There are actually much better ways to format documents on a Unix system. The traditional way, which is likely to be available on your system out of the box, is to use troff (nowadays ditroff or its GNU equivalent groff). This allows you to markup the text using commands like \fBbold\fP and \fIitalics\fP. This is the system used for formatting manual pages. To convert the markup into PDF, install Ghostscript, and use a sequence like the following.

groff -Tps mydocument.ms >mydocument.ps
ps2pdf mydocument.ps mydocument.pdf

However, if you want to learn a system that you can build-on, I suggest to learn LaTeX. This has a more intuitive markup language (e.g. you write \section{My Section Title}) as well as thousands of add-on packages and fonts. Most Mathematics and Physics papers are written in it. In this case, the command you would use to convert your document into PDF would be something like.

pdflatex mydocument.tex
3
  • This solution will probably work, as Latex. Will report back once I have tried it while finishing up The Help. Feb 7, 2013 at 15:46
  • 1
    Just as an update, I have learned LaTeX (slight learning curve), and BibTex (Steeper, but better documented with google), and am loving both. RTF submissions are now a thing of the past! Even on my Mac, I edit using SSH into the linux boxes with LaTeX installed. Mar 19, 2013 at 14:42
  • I'm glad you found the truth! You can also install LaTeX on your Mac. It runs fine. Mar 20, 2013 at 19:02
4

pandoc can convert a variety of markup texts into a wide variety of formats, including RTF.

Pandoc is a Haskell library for converting from one markup format to
another, and a command-line tool that uses this library. It can read
markdown and (subsets of) Textile, reStructuredText, HTML, LaTeX, MediaWiki
markup, and DocBook XML; and it can write plain text, markdown,
reStructuredText, XHTML, HTML 5, LaTeX (including beamer slide shows),
ConTeXt, RTF, DocBook XML, OpenDocument XML, ODT, Word docx, GNU Texinfo,
MediaWiki markup, EPUB (v2 or v3), FictionBook2, Textile, groff man pages,
Emacs Org-Mode, AsciiDoc, and Slidy, Slideous, DZSlides, or S5 HTML slide
shows. It can also produce PDF output on systems where LaTeX is installed.
2
  • Definitely a tool I will add to my computer! Long term, however, I have been convinced to try Latex more. Need the RTF capability, though, so thanks. Feb 7, 2013 at 15:48
  • 1
    Haskell, unforunately, isn't yet available on the Raspberry Pi. However, I have added it to my other CLI machines because it is still useful over SSH and SCP. Feb 7, 2013 at 22:09
2

While I too think Pandoc (Reed Kraft-Murphy's answer) might be perfect here, I'd like to point out that there's also WordGrinder, a little more WYSIWYG-like:

WordGrinder screenshot

It features HTML import and export as well as LaTeX and Troff export.

2
  • Will be working on this for sure in some cases.... Some teachers just can't take the hint "Yes, it has strange characters, and no, you can't tell what it is just by reading over my shoulder, but trust me, it will be pretty when it is printed." Oh, and didn't you know that the command line is for idiots who don't actually want to do anything productive? My teachers all know it! Thanks! Feb 7, 2013 at 15:50
  • I can't get it to install on either my Pi or my other boxes, even the Ubuntu Server box. Shame. Feb 8, 2013 at 0:27
2

If your needs are modest, consider one of the lightweight markup formats. The most popular are Markdown (what Stack Overflow / Stack Exchange uses, too) and reStructured Text.

I have only seen Markdown to HTML converters, but it should be easy to take it from there. RST has TeX conversion, too.

For what it's worth, I did my Master's Thesis in RST, but it was painful in places, and I ended up doing the final layout / pagination in OpenOffice. I also tried a HTML to PDF converter but it had issues with Unicode, and I wanted more control over the end result than straight machine conversion.

1
  • I did another paper in Markdown using Pandoc. This worked better than reST for me (though perhaps that too has developed in the meantime) and is what I plan to use for future projects.
    – tripleee
    May 6, 2016 at 18:54
2

I don't believe there is, your question is similar to this:

Using Vim to edit Microsoft Word files | Stack Overflow

If you could use LaTeX, then converting them to rtf shouldn't be too difficult.

It would help to explain why you're trying to edit rtf files; the solution is probably going to look something like:

  1. scp (or ftp or samba or what not) transfer the file to your local machine

  2. Edit file locally

  3. Upload finished file

Alternatively, installing X11 (and possibly vnc) on one of those machines would seem the way to go. Another option would be to convert them to html with Open Office (which I believe can do batch jobs from command line), edit them, and then convert them back. But the end result is the same; I've never seen or heard of a cli editor that can reasonably edit *.rtf files directly (short of editing the very large files themselves.)

3
  • Editing some markup designed for human consumption (be it troff, (La)TeX, docbook) is definitely preferrable to RTF.
    – vonbrand
    Feb 7, 2013 at 3:21
  • I'd just like to point out that most of the stuff you see in a RTF file (The first thousand+ lines generated by Microsoft Word) is 38kB of crud formatting that is unnecessary. Most editors work without that. Really, RTF is a very lightweight markup language, best known for being useable on every Mac, Windows Box, and (I suppose) not natively on Linux. Feb 7, 2013 at 12:31
  • Oh, and I need to edit RTF files (probably) because that way I can use the stupid school computers to print my work. I hate printers. But I think the PDF options mentioned should work. Feb 7, 2013 at 12:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .