Project 36. Edit with GUI-Based Editors"Can I use 'normal' editors, with mouse clicks and menus, to edit configuration files and write shell scripts?" This project takes a brief look at using graphical editors that run in the Mac OS X Aqua environment. It touches on Apple's TextEdit and on TextWranglera free editor from Bare Bones Software. Configure Your EditorIt's perfectly acceptable to use a graphical-based text editor to write code and shell scripts, and to edit Unix configuration files. There's one drawback, though: Your Unix colleagues may mock you for not "doing it the Unix way" Keep It PlainIf you use an OS X text editor, there is one golden rule you must follow: Make sure your files are saved as plain text. Word processors and Rich Text editors embed unwanted font and formatting information in files. Also, choose a fixed-width font so that columns align correctly, and choose a face in which the letters l and O (ell and oh) are clearly distinguishable from the digits 1 and 0. Line BreaksWatch out for line-break characters. Traditional Macintosh editors use a carriage return (CR, ASCII character code 13) to break lines. Unix requires a line feed (LF, ASCII character code 10). If your editor has an appropriate option or preference, make sure it is set to write Unix line feeds. If you find yourself with text files that contain Mac-style line breaks, the contents of those files will appear to Unix commands to be one long line. A simple way to fix this is to use the command tr, which translates a file containing CR breaks into one with LF breaks. $ tr '\r' '\n' < mac-file > unix-file Note
Edit as RootSystem configuration files are writable only by root. You'll find it more difficult to edit such files in a graphical editor. Some editors, such as TextWrangler (discussed later in this project), recognize this situation and will ask you to authenticate to modify the file. TextEditApple's TextEdit application can be used to edit Unix files. If you ensure that the file is plain text (Figure 4.5), TextEdit will write Unix LF characters automatically when the file is saved. Figure 4.5. Choose Format > Make Plain Text in TextEdit if you're working on Unix files.![]() Learn More
Learn More
If you try to edit an HTML file with TextEdit, you'll find the program suffering an identity crisis: It suddenly becomes a browser. It will let you edit displayed text, but it won't show you the HTML tags in the file. As a clunky workaround, open the file you want to edit in Safari, and choose Source > View Source. Copy the HTML text that's displayed, and paste it in to a new plain-text TextEdit file. TextWranglerTextWrangler (Figure 4.6) is an excellent programmer's editor, available as a free download from the Bare Bones Software web site, (www.barebones.com). Figure 4.6. TextWrangler, the free text editor from Bare Bones Software, is a Mac OS X application that's outstanding for editing Unix files.![]() As a programmer's editor, TextWrangler has some powerful features, such as:
|