Monday, October 8, 2012

How to get the host IP address to appear in a bash command prompt on OSX

This was done on OSX Mountain Lion.

Simply modify .bashrc to use the PS1= construct:

PS1="[\u@\[\e[0;33m\]MBP @ `ifconfig|grep broadcast|awk ' { print $2 }'` \[\e[0m\]\W]$ "

The key bit is enclosed in `...`.  Note that modifying this for other *nix systems requires fiddling with the search string.  Also note that the complex [\e[0;33m\]... construct controls the prompt color.  There are some great online tutorials about that.  Just Google "bash color prompt".

Result:
PS1 line in .bashrc to get IP address in command prompt on OSX.

Saturday, October 6, 2012

Copy full path of file in DevonThink Pro Office to clipboard

Relatively often I want easy access to the full path of a file previously imported to DTPO.  This often happens when I need to upload a file to a website.  The "Reveal in Finder" toolbar button is useful, but doesn't give you access to the text of the full path.  I used Automator to create a little application that I saved in the DTPO "Scripts->Toolbar" folder.

Step One:  Download the "Get File Path" Automator action from this page.  Install the action within Automator using the "File->Import Actions..." menu option.

Automator window showing the entire script, and the "import Actions..." button.

Step Two:  Create a new Automator Applications project.  Using the search field at left, search for all actions with "Records" in the title.  Drag the "Get Selected Records" to your new project.  Follow this with "Get Item from Record".  Next add the "Get File Path" that you just downloaded.  I recommend setting the options to extract an escaped POSIX (unix style) path name.  To complete the script, simply drag the "Copy To Clipboard" action to the end of the "code".

Step Three:  Choose save, and save your new tool to:
~/Library/Application Support/DEVONthink\ Pro\ 2/Scripts/Toolbar
Once the workflow has been saved like this, you need to restart DTPO.  Then look in the scripts menu available in DTPO, and,  if you have selected a file or folder in DTPO, your new script should be visible under the "Tool-bar.  It should also be available to add to the toolbar itself when you customize the toolbar.

DTPO window with the "Get Path" script on the toolbar (it's the little clipboard that says "Path" under it!).
The output of the script is the full pathname extracted to the Clipboard, entirely ready to be useful!  I gave my version a cute little logo, but this is not required!

Let me know questions or comments below!

Friday, October 5, 2012

Importing an entire web*site* to DevonThink Pro Office

I use the "Clip to Devonthink" Safari extension to grab webpages.  I find that it works great!  But what about entire web sites?  I actually encountered this because I had exported a journal-style file as a website, and wanted to import it as a whole into DTPO.  The web site style maintains beautiful formatting, and very functional link based navigation scheme... as opposed to a linear document format that would be available from a printout of the content to a PDF.

Clip to Devonthink doesn't appear to clip "file://" pages, and even if it did, I wasn't sure how complete the "web archive" option would be.  A bit of googling suggested that the "Import Site" menu option:
DTPO "Import Site..." menu option.
This works!... with one major caveat: if you import a "web site" from a local disk, it looks like DTPO relies on those files not moving... which somewhat diminishes the value of the import.  In contrast, DTPO appears to download and fully import sites actually on the web.  The trick is to specify the top page in the site (generally the index.html page), and make sure to specify the "Subdirectory (Complete)" option by right clicking on the queued website.
DTPO "Import Site..." dialog in the Download Manager.  Enter the site location, then make sure to select the "Subdirectory (Complete)" option.
A couple of additional notes:  If the download just happens before you have a chance to set the option, click the pause button at the bottom of the Download Manager window.  Then get your queue of downloads all set, and click the play button.

The Download Manager will remain open until you close it, and will remain in "run" mode until you pause it... so watch out during multiple sequential site downloads.