Redirecting wget to STDOUT – now with Syntax Highlighting

Stefan - 7. August 2007

Sometimes the simplest looking tasks can become complicated, especially when modern computers are involved. Today I tried to examine the source code of some RSS feeds. Safari shows me a very nice HTMLified version of the feed. Of course this is useful for most of the Safari users, but it can get in your way when you try to develop a RSS based web application. But any up-to-date computer geek has more than one browser installed, so I fired up Firefox and tried to access the feed. Wow, even Firefox tries to be smarter than me and redirects me to my Bloglines account. (I’m sure this is a feature I’ve activated some time ago, but have no idea how to switch it off.)

Having a nice command line at hand, there should be an easy way to look at an RSS feed, but wget displays just some crap, if I redirect its output to STDOUT. But wait, I forgot to make wget quiet. And really, now it works and it’s a very simple way to look at my RSS feeds:
wget -qO- http://www.fischerlaender.net/feed | less

Update:
There’s even a way to get syntax highlighting! If you’ve installed a reasonably up-to-date version of vi(m), there is a script called less.sh in your $VIMRUNTIME directory, which acts as an replacement of less providing syntax highlighting.

To use this script on Mac OS X Tiger, you just have to follow these simple steps:

  • Launch vi and type :echo $VIMRUNTIME. This shows you the path to the
    vi files. On my MacBook this is /usr/share/vim/vim62.
  • Now execute sudo ln -s /usr/share/vim/vim62/macros/less.sh /usr/bin/vless. If you’ve
    got another path before, you have to edit this command appropriately.
  • That’s all. Now vless acts nearly as less with syntax highlighting.

Of course, vless can also be used within shell pipes:
wget -qO- http://www.fischerlaender.net/feed | vless

Abgelegt in: Web Development

7 Kommentare:

Für Firefox: Unter den Einstellungen im Reiter “Feeds” kann man den RSS-Client bzw. “Vorschau anzeigen” auswählen. Dann bekommt man aber immer noch nicht den Feedquelltext zu sehen, sondern muss dann nochmal die Quelltextanzeige bemühen…

Da ist wget natürlich etwas fixer ;)

Thnks. nice tip.

Not everyone speaks German. It would be nice to translate this comment into English…

[…] This entry is based on this post: Redirecting wget to STDOUT – now with Syntax Highlighting. […]

[…] References Redirecting wget to STDOUT – now with Syntax Highlighting […]

In my browser, the command looks like this:

wget -qO-

which doesn’t work. Correct:

wget -q -O –

In words: dash, lower-case letter Q, space, dash, upper-case latter O, space, dash.

Hi Christopher,
thank you for your hint. I think it’s system dependent whether the shortcut version -qO- works or not. So, it’ll be indeed safer to try your version.
Stefan

Schreibe einen Kommentar
benötigt
benötigt (wird nicht angezeigt)
optional

Suchen