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.

6 Comments »

  1. Remote man pages at Mac Singularity said,

    January 16, 2007 at 11:47 am

    [...] This pretty slick trick tells how to open remote man pages with BBEdit. I think it’s definining some sort of function in bash? I’ve never seen the function command used before, so I assume it’s a trick with some shell. [...]

  2. juandesant said,

    January 16, 2007 at 11:55 am

    Thanks for the tip!

    However, I find there is a semicolon missing at the end (at least for bash):

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

    If you don’t use BBEdit, but you have TextWrangler with the command line tool installed, you can change that into:

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

    And if you’re, instead, a TextMate junkie:

    function manb () { ssh $1 man $2 | col -b | mate; }

    This last version doesn’t show you a proper title, because the mate command line tool doesn’t provide a flag for it…

  3. reppep said,

    January 16, 2007 at 12:07 pm

    Mac Singularity: Yes, it’s a bash function — they’re obscure, but more flexible than aliases.

    juandesant: Interesting. I have the semicolon on another shell function, but this one works without it for me.

  4. sahil said,

    January 16, 2007 at 11:26 pm

    This is not elegant but will show you a proper title in TextMate:

    function manb () { ssh $1 man $2 | col -b > $2@$1; mate -w $2@$1; rm -rf $2@$1; }

  5. thePervertedMonk said,

    January 17, 2007 at 12:40 am

    I made a adjustments to the function to allow for more customizations if you’re like me and you happen to use BBEdit/ TextMate and/or TextWrangler interchangeably.

    -function operates as before, just pass either -bb or -tw or -tx as the final parameter to choose your editor of choice (BBEdit/ TextWranger/ TextMate, respectively). -if the function is called with an editor, it defaults to TextMate, this can be changed by editting the last condition.

    function man_ssh () { case $3 in “-bb”) ssh $1 man $2 | col -b | bbedit -t “$2@$1″ –clean –view-top ;;

        "-tx")
            ssh $1 man $2 | col -b | mate
            ;;
    
        "-tw")
            ssh $1 man $2 | col -b | edit -t "$2@$1" --clean --view-top
            ;;          
    
        *)  # default
            ssh $1 man $2 | col -b | mate
            return
            ;;
    esac
    

    }

  6. the Perverted Monk» posts archive » CLI Magic: view remote man pages | "mundane monkish musings..." said,

    March 1, 2007 at 4:12 pm

    [...] do an ‘ssh [remote_host] man [remote_command] | less‘, but while visiting this post at Extra Pepperoni, I was inspired, expanded on the original, and posted it there. [↩]Article Series - CLI MagicCLI [...]

RSS feed for comments on this post · TrackBack URL

Leave a Comment

You must be logged in to post a comment.