Extra Pepperoni

To content | To menu | To search

Sunday, September 28 2008

Windows Annoyances: September 2008 Update

I've been using Windows regularly for a while now. I have many gripes. I realize Vista and Office 2007 fix some of these, but I'm pretty sure they'd be aggravatingly slow on my desktop PC, where Windows XP isn't. Note that I have complained about most of these here -- this post is a consolidation & update.

Windows

  • In the Alt-Tab task switcher, I cannot Hide (Command-H), Quit (Command-Q), or click an application's icon to switch directly to it. This is aggravated by the fact that icons in the switcher often correspond to windows rather than on the Mac, where they correspond to applications (each with one or more windows), so there are many more icons to Tab through, and often several indistinguishable windows (4 Firefox windows generate 4 identical unlabeled icons; so do 4 open messages in Outlook). Considering Windows has had this feature for longer than Apple, it's shockingly lame.
  • I cannot hide the current application (window) from the keyboard (Command-H), or Hide Others (Command-Option-H).
  • I want to drag icons onto applications. The Start bar, Windows' equivalent of the Dock, doesn't accept dragged files -- Microsoft knows it should because it pops up a message when I try, but they didn't make it work.
  • I want to drag proxy icons from document windows into other windows (typically Outlook messages). Proxy icons seem like such a minor thing, but Apple introduced them years ago, and I feel the lack in XP keenly.

Text (UltraEdit, UltraCompare Lite, & kate)

  • I miss BBEdit. UltraEdit is very good, but BBEdit has many advantages, and I haven't yet encountered any UE advantages (although presumably there are some). I use UE and vi daily, and kate periodically -- when it's faster than vi but not worth bringing the files back to my desktop, or pointing UE to my account on a UNIX box.
  • kate is broken in several ways, although I'm not sure how much to blame Exceed. Specifically, Copy & Paste are unreliable (sometimes they both work, sometimes only one direction works, and sometimes neither works!). Shift-selection from the keyboard doesn't work. Tip: In Exceed, assign the left modifier keys to X11 instead of Windows.
  • I really miss the bbedit command, particularly for opening local and sftp files from the command line. I miss being able to bbedit in a loop!
  • In Windows, Control-Backspace works in some places, but inserts non-printing ('box') characters in others.
  • I see that UltraEdit offers 4 different flavors of Find & Replace: Plain, perl regex, UNIX regex, and UltraEdit regex. This seems crazy to me -- I consider anything that's not 100% backward-compatible with PCRE a bug, but I am not selling to a population of users who live in MS Word. BBEdit's is based on PCRE.
  • BBEdit's Find Differences is much better than either UE's (both files must be in a rooted window, and UltraCompare Lite is confusing and awkward). kate uses kompare, which is pretty weak. Neither kompare nor UltraCompare is very well integrated. BBEdit v9 makes major improvements to Find Differences.
  • UltraCompare Lite (like UltraEdit) displays documents inside a root window, which makes comparing across 2 monitors a pain, since the root window must be manually sized to cover 2 displays.
  • UltraCompare Lite doesn't have BBEdit's (new) character-level comparison, which I've wanted for years.
  • UltraCompare cannot compare unsaved windows.
  • UltraCompare's merge functionality is very confusing -- there are lots of obscure buttons, and some simply don't work. Manually copying from one document to another is a pain, as it requires a switch to UltraEdit (the UC docs aren't editable) and a re-compare (leaving the original one open) to get a fresh comparison.

Internet Explorer 7

  • I can increase the font size, but if I do the window grows beyond the window size -- there's some brain-dead full-page magnification, rather than the classic (and useful) text size increase.
  • If I increase the font size, selection highlights no longer align with the text I'm dragging over. It's bizarre.
  • In PDF tabs, Control-W doesn't work; I find this extremely aggravating, but fortunately Command-W works fine in Safari (even with the Acrobat plug-in).
  • I still hit Control-L to select the URL for copying, and IE7 still fails to do it, bringing up a blank URL entry dialog, instead of selecting the URL in the current window as Safari & Firefox do. I shouldn't need to use Alt-D instead to select the current URL. That Control-L window has no reason for being.

Misc

  • MS Office Communicator flashes in the Start bar, many times, whenever someone types to me (unless that window is already in the foreground). It's very distracting -- on the Mac I tend to turn this off, or set it to only once. For some reason it annoys me more on Windows.
  • When someone sends me a message in Communicator, the "buddy list" window's icon flashes in the Alt-Tab task switcher, rather than the updated conversation.
  • I open a bunch of programs whenever I log in, so I created a batch file to launch several applications and PuTTY sessions. Unfortunately, it launches one application and then stops. In a UNIX (Mac) shell, I'd use a trailing & on each command, so the script could continue to the next one without waiting, but I was unable to find a working equivalent for .bat files.
  • The inevitable overnight reboots are quite disruptive. They make me appreciate the Mac more, where this kind of thing is less common, and the system (Finder) makes an effort to resume where I left off.

Thursday, August 7 2008

UltraEdit

I've been a serious BBEdit user for years (I suspect a beta password many years ago was a joke at my expense). I use vi daily but am not a fan, and I find emacs inexplicable. As an system administrator, editing text files (typically configuration files and scripts) is a large part of my job.

So spending my days using Windows, with no BBEdit, was a concern.

I used kate a bit, and it's not bad, but it's limited (cannot even compare 2 windows!), and Exceed's Copy & Paste support is extremely erratic.

Many people suggested UltraEdit, but due to an installer issue, I was unable to use it. That issue has been fixed, and I got it running today. I'm quite impressed, although I have already discovered that its sorting capability is downright feeble compared to BBEdit's GREP-enhanced sorting. I see that UltraEdit offers 4 different flavors of Find & Replace: Plain, perl regex, UNIX regex, and UltraEdit regex. This seems crazy to me -- I consider anything that's not 100% backward-compatible with PCRE a bug, but I am not selling to a population of users who live in MS Word.

Truly weak: Find for $ doesn't work properly in perl regex mode with UNIX line endings.

I am both impressed and mildly aggravated. UltraEdit is much better than anything else I've used on Windows (or Linux or Solaris), but it's also less polished than BBEdit. I'm not sure how much of my frustration is because I have the advantage of years of experience of BBEdit -- compared to only a few hours to learn UE so far -- and how much is real deficiencies and lack of polish in UE.

Tuesday, March 18 2008

kate Is Not Bad

I got Exceed, and after reassigning my left modifiers to X instead of Windows, kate is quite reasonable. It uses kompare for graphical diff, and comes with some CVS plugins. I prefer BBEdit's diff display (although BBEdit's diff has been broken for years). I'm not sure how I managed to view a couple windows in xemacs from kompare, but I can probably avoid that in the future...

kate is clunkier and less featureful, and not as configurable as I expect -- the commands I want to assign to the toolbar, for instance, are not available in that context. On the other hand, BBEdit doesn't use a toolbar at all, and rearranging menus is only supported in limited ways, so I'm not convinced kate is inferior here -- it may just feel like that to me as a BBEdit user. Hopefully Subversion support is available for kate, but that doesn't actually matter to me right now.

I need to get Copy & Paste working between Windows (including PuTTY) and Exceed; hopefully this will be straighforward, but it doesn't just work.

Per IDM, UltraEdit cannot be installed without admin rights, which I do not expect to get, so that's out -- at least until they offer an alternate installer.

kate icons are a bit fuzzy, but they fit the Linux aesthetic, and the fonts are very nice.

Saturday, March 8 2008

Windows and Outlook Annoyances

I've been using Windows on a daily basis for 9 days now. At Rockefeller, I kept it on a VM (earlier, on a physical PC) which I could easily wipe and reinstall. I kept the few installers I need on a Mac so I could easily reinstall and be back in business. Now I have to do much more in XP/Outlook, and I have many gripes.

Things I Miss

These are mostly lacks in Windows, although not entirely.

  • In the Alt-Tab task switcher, I cannot Hide (Command-H), Quit (Command-Q), or click an application's icon to switch directly to it. This is aggravated by the fact that icons in the switcher often correspond to windows rather than on the Mac, where they correspond to applications (each with one or more windows), so there are many more icons to Tab through, and often several indistinguishable windows (4 Firefox windows generate 4 identical unlabeled icons; so do 4 open messages in Outlook). Considering Windows has had this feature for longer than Apple, it's shockingly underpowered.
  • I cannot hide the current application (window) from the keyboard (Command-H), or Hide Others (Command-Option-H).
  • I miss BBEdit -- working with notepad and vi for now; UltraEdit's installer (recommended on TidBITS-Talk) doesn't work in my environment. This will get worse as I start writing and editing more (code).
  • BBEdit (particularly side-by-side diff and interactive reconciliation, which I should be able to find an alternative for, but sdiff isn't it).
  • bbedit (I miss opening files from the shell, including via sftp and from for loops).
  • ssh keys for authentication.
  • Seeing my personal email throughout the day -- the financial/SEC/Sarbanes-Oxley environment requires a lot more separation between personal and work activities.
  • Options (program-wide preferences) is not available from message windows -- only from the mailbox viewer window. This is true in Thunderbird/Mac too; presumably copied from the MS model.
  • Good filtering: Outlook's filtering is very much wizard-driven, but not very flexible (no booleans & very limited criteria available); two filters that try to file the same message will put 2 "copies" of the message in different mailboxes; some options are handled on the server, while others are only performed on the client.
  • BlackBerry filtering: The BlackBerry Curve shows everything in one mailbox; I'd like to see things grouped as I do on Outlook.

Things that bug me

  • I can make Outlook sort a mailbox with the newest messages at the bottom (the default is newest-at-top), but then when I click the mailbox, Outlook selects the bottom (newest) message in a mailbox, whereas I want to read oldest first.
  • I can make Outlook allow commas as address delimiters (which is what they are in the actual mail messages), but then I cannot type names, because we have autocomplete disabled and Outlook doesn't recognize a correct "Last, First" recipient when it's set to allow commas as delimiters (even though Outlook uses them once I click Check Names).
  • Keyboard nickname completion (Command-L in Eudora); I can't find a way to assign a keyboard shortcut to Check Names.
  • I try to keep my mailbox "caught up" or "clean" (all messages read). Outlook doesn't mark a message read until I deselect it. This means that when I'm done, to have it stop showing that last message as unread, I have to select something else.
  • When I'm reading a bunch of new messages, and Outlook selects one I don't want to read (see above about selecting the bottom/newest message), I have to click another message to get the Mark Unread contextual menu command; then I scroll up to the top and click on the first message.
  • AutoCorrect absolutely would not let me type "SAs" (System Administrators) until I killed it.
  • MS Office Communicator flashes in the Start bar and the Alt-Tab switcher, but it flashes the main window's icon, instead of the one for the conversation with new activity. That's just dumb.

Things I like

  • Outlook can show me mailing list (group) membership. It's called "Outlook Properties" in the menu, despite being maintained on the Exchange side, but after I got over thinking that couldn't be the right place, this is quite handy.
  • Outlook checks group memberships automatically when filtering; this cannot be turned off, so I cannot filter messages sent to a list separately from messages sent to a member of the list.

Monday, September 24 2007

iPhone Link Farming

The iPhone doesn't support a start/home page. Every time you open a new Safari page (equivalent to a tab) it opens to a new page, unless you open it from another page with a "target" attribute. Fortunately, its MobileSafari browser is very smart about suggesting recently visited sites; typing one or two letters typically brings up the site I want as a suggestion. Email addressing works the same way -- it appears to prioritize recently used addresses, so if you visit the same sitesĀ (or email the same correspondents) repeatedly, it's usually right.

On the other hand, sometimes you want a "link farm" (bookmarks page). I keep one with a bunch of links, both for use on the iPhone itself and also for visiting on Macs for working with the iPhone: http://www.reppep.com/~pepper/iphone/. I'm a big fan of tabbed browsing on desktop computers (ever notice how, in relation to iPhones and other handheld computers, laptops become "desktops"?). On the iPhone, I prefer to keep my bookmark page open, and open new tabs off it. There's a JavaScript bookmarklet to make every link open a new window, but it doesn't do the trick for me.

Instead I keep my iPhone bookmarks on a simple page containing a few lists of links. Since this page changes frequently, I have a BBEdit GREP Pattern to do the necessary. It converts a plain URL, into a proper <a> tag with a unique target attribute (the hostname), and wraps the whole thing in a <li>/</li> pair; this gives me a readable and clickable link that opens in a new window. I tried target="_new" and target="_blank", but no joy. Here's the pattern, to save time for future link farmers...

Search for: ^(https?://)([^/\r]+)(.*)$

Replace with: \t<li><a href="\1\2\3" target="\2">\1\2\3</a></li>

Wednesday, June 20 2007

Daring Fireball Visits NYC

John Gruber (Daring Fireball) gave a presentation at the SoHo Apple Store tonight. I might've been annoyed it was a repeat of his C4[0] presentation, except I wasn't at C4 so I hadn't heard it. The rest of the audience seemed suitably impressed -- Apple brought extra chairs, and there were still a bunch of people sitting on the floor.

Afterwards, I tagged along to a yummy Vietnamese restaurant. We left when all the unoccupied chairs had been placed on the tables around us, only to discover a giant (empty) drum of MSG outside the front door. This sparked a brief but lively discussion of whether MSG is in fact as bad for you (us) as people once claimed, with no real resolution.

I liked Gruber's description of Jonas fuzzing, "I need a hole."

Tuesday, June 5 2007

Markdown.cgi v1.3: Fixing the Markdown Source

Whoops! I wrote Markdown.cgi so I could easily preview Markdown content in BBEdit, but 1.2 broke this. As a fix, instead of using .markdown for source and .text to see the HTML output, v1.3 goes back to using .text files, and now ?markdown appended to the URL returns the Markdown source.

I considered allowing additional query arguments, but Apple's sh and expr string matching is quite limited, and I don't want to make the whole thing any slower or more complicated than necessary. Fortunately, it would be easy to change the 'magic' query string. Just change the 'markdown' literal on line 7.

I also moved the downloadable (.txt) script, to make the older versions available, and so I can avoid pointing people to old versions.

http://www.reppep.com/~pepper/code/Markdown.cgi/

Thursday, May 24 2007

Markdown.cgi: Markdown in Apache httpd

I've written a couple articles for TidBITS since they started using John Gruber's Markdown format, and despite actually liking HTML as a writing format, I was impressed with Markdown's simplicity and efficiency (no <p>s are a big time savings!).

So I installed PHP Markdown Extra here on Extra Pepperoni, and got hooked on writing in Markdown. Unfortunately, there's no Markdown plug-in for plain Apache -- lots of ways to parse Markdown in your blogging software or wiki or CMS, but I want to be able to write a .text file and serve it up 'directly' from Apache on www.reppep.com.

Update: Markdown.cgi has been updated. Check my Markdown category for the latest.

Markdown is designed to run as a simple filter, so it's well suited to drop-in installation in a lot of places, without having to build customized versions for a particular application's APIs. There are several implementations -- the original Perl script, as well as versions in PHP (which I use in WordPress, slightly hacked), Python, Ruby, JavaScript, etc. http://markdown.infogami.com/ keeps a list.

Since I couldn't find an Apache handler (plug-in) or a CGI for Markdown, I wrote a very simple wrapper for Gruber's Markdown.pl. Conceptually, my wrapper spits out an HTML header, uses Markdown.pl to render the requested page as (X)HTML, and then appends an (X)HTML footer. The reality is slightly more complicated, due to the vagaries of figuring out the document's title, and conditionally inserting it back into the output as an <H1> tag. Even so, the whole thing is under 60 lines, mostly whitespace and comments.

Markdown.cgi also solves a problem which has wasted a significant amount of my time. BBEdit's built-in Preview tool can use Markdown.pl to generate HTML, which it then passes to WebKit for previewing in a formatted window. But if you put the pages on a real active website, BBEdit has another feature I really like, whereby it will actually calculate a live URL for the page to be previewed, request that URL from the web server, and preview that instead.

This is great, but if you're writing Markdown, BBEdit shows you the unrendered Markdown code (as served up by the web server), instead of rendering the Markdown file from disk. To make matters worse, BBEdit's Preview is live in real time, but continuously re-rendering a Markdown document as you type makes BBEdit stall badly on my 1.5GHz PBG4, so I've stopped using it as a live preview. I instead trained myself to use Markdown.pl as a UNIX script, which I manually trigger to generate a temporary HTML document. I then view this document in BBEdit's live Preview. Among other things, I frequently found myself editing the scratch HTML document, and having to copy my changes back to the Markdown source. Yuck.

Now that my web servers can serve up Markdown .text documents in HTML format, I can skip that whole mess, and go back to previewing .text documents (using Safari or BBEdit's live Preview) with server-side HTML conversion, seeing exactly what surfers see, as Siegel intended.

Tip: If you're reading about or trying out Markdown, don't read the syntax page -- skip to the simple crib sheet on the Dingus page. It's much simpler (and shorter!).


To implement this, I added some lines to my Apache httpd (1.3) configuration, inside the main vhost block:

Action markdown /cgi-bin/Markdown.cgi
AddHandler markdown .text
AddType text/html .text
ScriptAlias /cgi-bin/ /home/web/www.reppep.com/cgi-bin/
AddType text/html .pl

Here is Markdown.cgi, although I had to rename this copy Markdown.txt so you can download it:

#!/bin/sh
# Markdown v1.1.1 2007/05/24
# Build an HTML page (with headers) from Markdown.pl output.

INCLUDES=/home/web/www.reppep.com/include
TITLE=`head -1 $PATH_TRANSLATED | cut -f2`
echo "Content-type: text/html"
echo

cat $INCLUDES/head1.incl
echo $TITLE
cat $INCLUDES/head2.incl

# If we already have an H1, don't insert one.
if ! grep --silent '^# ' $PATH_TRANSLATED
 then
  echo -n '<h1>'
  echo -n $TITLE
  echo '</h1>'
  echo
fi

/usr/local/bin/Markdown.pl < $PATH_TRANSLATED

cat $INCLUDES/foot.incl

exit 0

# http://www.extrapepperoni.com/2007/05/24/markdowncgi-using-markdown-in-apache-httpd/
# http://daringfireball.net/projects/markdown/

# To use, copy Markdown.cgi (this wrapper, which you may have to rename
# from Markdown.txt) and Markdown.pl (from Daring Fireball) into your
# cgi-bin/ and make them executable
# ("chmod +x Markdown.cgi Markdown.pl"), set the correct path for
# INCLUDES below, and install head1.incl (HTML header up to <title>),
# head2.incl (HTML header starting with </title>), and foot.incl in
# that directory.

# Markdown.cgi reads the page's title from the first line, starting
# after the first tab and ending before the second.
# Your document's title should be inside an HTML comment, set off by tabs.
# The title line contains 5 parts:
# 1) the HTML comment open delimiter (less-bang-dash-dash)
# 2) a tab
# 3) the title text
# 4) a tab
# 5) the HTML comment close delimiter (dash-dash-greater)
# For example (not counting the # on the next line):
#<!--   Markdown.cgi: A Simple Wrapper for Markdown.pl  -->

# Add the following to your Apache httpd configuration
# (likely httpd.conf or a virtual host .conf file):
#   AddHandler markdown .text
#   Action markdown /cgi-bin/Markdown.cgi
#   AddType text/html .text
#   ScriptAlias /cgi-bin/ /home/web/www.reppep.com/cgi-bin/
#   AddType text/html .pl

My header and footer are dead simple, but easy to replace with something more sophisticated.

head1.incl:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>

head2.incl:

    </title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>
<body>

foot.incl:

<hr />

<p align="center"><small><a href="./">home</a></small></p>

</body>
</html>

Thursday, February 8 2007

Remote Control and Reminders

Frequently, I need to leave myself a reminder or send myself a note on another Mac. I used to do this via email, but now mostly use ssh, with the open and bbedit commands. Since I use ssh private keys for authentication, this is very convenient -- I can issue commands to remote machines without having to enter a password each time.

Since I ssh so often, I've set up several convenience aliases, including ss for "ssh salt" and sc for "ssh cayenne".

For several years I wished for remote clipboard support; I believe Peter Lewis even wrote a tool to implement it, and there are remote control tools such as VNC, but this is simpler and quicker.


Here are some examples of useful remote commands:

Open a BBEdit window on salt, showing the entered serial number:

echo "Serial Number for Some Super Software" | ss bbedit

Open an article in Safari, on cayenne:

sc open http://db.tidbits.com/article/8835

Open a couple pages in Safari on cayenne, including one with punctuation in the URL that would normally trip up the shell:

sc 'open http://blogs.zdnet.com/threatchaos/?p=311 http://daringfireball.net/2007/02/more_crap_from_enderle'

I keep most of my systems on all the time, so it's extremely handy to be able to toss text and URLs around this way.

Serious UNIX nerds can use cat to send a block of text over (Control-D at the end terminates text entry and bundles off the text):

cat - | ss bbedit
This is a test.
This is only a test.
If this was a real emergency, you'd be dead already.
^D

Alternatively, create a text file via a normal ssh session, and open it for later -- this is not as fast, but conceptually closer to normal usage:

pepper@www:~$ ss
Last login: Thu Feb  8 18:13:36 2007 from www.reppep.com
Welcome to Darwin!
pepper@salt:~$ vi Desktop/note.txt
[Type, paste, whatever, here; then save and exit vi]
pepper@salt:~$ bbedit Desktop/note.txt
pepper@salt:~$ logout
Connection to salt.rockefeller.edu closed.
pepper@www:~$ 

Additionally, I do something similar to remind myself to edit or update documents when I get home, which looks something like this:

sc bbedit www/pepper/public_html/index.html

Monday, January 8 2007

Remote 'man' with BBEdit

I frequently need to read manual pages from Suns and Linux systems, but prefer to read in BBEdit. Today's trick facilitates this, by grabbing the manual page from a remote machine via ssh, unformatting it with col, and dumping it into a BBEdit window (which doesn't ask to be saved).

function manb () { ssh $1 man $2 | col -b | bbedit -t "$2@$1" --clean --view-top }

Usage is "manb host command", so "manb www up2date" opens a window titled "up2date@www" with www's up2date manual page.

Friday, December 29 2006

BBEdit and Subversion: the Fruit Roll-up Post

I use vi daily, but much prefer BBEdit. The way I integrate them has evolved over time (see previous posts here, Useful subversion shell aliases, and BBEdit Gems (which appears to be down right now). In particular, I no longer configure BBEdit directly in ~/.subversion/config.

The new improved integration uses BBEdit whenever it's available (I'm in front of the Mac), and falls back to the default (vi) when I'm connected via ssh.

First, I created ~/bin/edit.sh to hand off to BBEdit. I use edit.sh whenever BBEdit is appropriate:

#!/bin/sh
# Edit in BBEdit, for programs that don't support arguments in $EDITOR.
bbedit --wait --resume "$@"

Next, I configured my bash profile to prefer edit.sh when I'm not connected via ssh (which means when I am in front of the Mac or using ARD/VNC), as my EDITOR and PAGER. My profile doesn't automatically determine whether to use bbdiff for Subversion, because I sometimes find it necessary to use non-BBEdit diff for Subversion (there are cases where the svn-to-bbedit handoff doesn't work well, and I have ended up editing scratch files instead of the real files, for instance). Here's the snippet that does this, from my profile:

if [[ ! $SSH_TTY ]]
then
  if [ -x ~/bin/edit.sh ]
    then
      export EDITOR=~/bin/edit.sh
    else export EDITOR=vi
  fi
  if [ -x /usr/bin/bbedit ]
    then export PAGER="col -b | bbedit --clean --view-top"
  fi
else export EDITOR=vi
fi # [[ ! $SSH_TTY ]]

In addition, I set up aliases for reviewing output from the svn command, based on Bob's suggestions. I just copy and paste one or more lines from svn output to review changes in BBEdit:

alias  A='bbedit --wait'
alias AM='bbedit --wait'
alias  C='bbedit --wait'
alias  D='true'
alias  G='svn diff --diff-cmd bbdiff --extensions "--resume --wait"'
alias  I='true'
alias  M='svn diff --diff-cmd bbdiff --extensions "--resume --wait"'
alias  R='svn diff --diff-cmd bbdiff --extensions "--resume --wait"'
alias  U='bbedit --wait'

I update and then review status so often that I built my own TLA:

alias sus='svn update

Monday, May 22 2006

BBEdit and Subversion

BBEdit and Subversion now play well together (actually it's since BBEdit 8.1, but I hadn't noticed at the time). I added a few lines to ~/.subversion/config:

[helpers]
diff-cmd = bbdiff
extensions = --wait --resume

Now "svn diff" (with or without arguments) does the right thing.

Update: svn honors $EDITOR.

Wednesday, May 3 2006

Using bbedit as My EDITOR and PAGER

When I'm in front of the Mac, I want to use use BBEdit as my EDITOR and PAGER. When I'm connected via ssh from another computer, I need to fall back to vi and less. The following snippets handle this for me. The first one goes in a shell initialization file such as .profile or .bashrc, and the second one is a separate shell script.

if [[ ! $SSH_TTY ]]
 then
  if [ -x ~/bin/edit.sh ]
   then export EDITOR=~/bin/edit.sh
  fi
  if [ -x /usr/bin/bbedit ]
   then export PAGER="col -b | bbedit --clean --view-top"
  fi
fi # [[ ! $SSH_TTY ]]
pepper@pepperbook:~$ cat bin/edit.sh 
#!/bin/sh
# Edit in BBEdit, for programs that don't support arguments in $EDITOR.
bbedit --wait --resume "$@"

BBEdit's command-line helper (bbedit), can invoke BBEdit, but normally returns immediately after passing along the specified file(s) -- it doesn't wait for the user to finish editing the file, as a standard UNIX editor would, so Bare Bones provides the -w option to make bbedit wait to return. Unfortunately, some programs won't run a program with arguments as EDITOR, so it has to be embedded into a shell-script that adds --wait --resume internally.

The PAGER bit is similar, and inspired by a TidBITS-Talk thread.