New Shell Worksheet for Window

Summary: Makes a shell worksheet for working on the current window’s file.
Requires: BBEdit 6.5, Mac OS X
Suggested Key Binding: Command-Option-Shift-1

Description

This script opens a new shell worksheet and sets the working directory to the parent folder of the current document. So, for instance, you can invoke the script and type “make<enter>” to compile/LaTeX/whatever the current file.

By default, the script is bound to Command-Option-!, because the roughly equivalent “shell-command” feature in Emacs is bound to M-!.

Download in Compiled Format · Download in Text Format

Script

tell application "BBEdit"
    
if class of window 1 is disk browser window then
        
set s to selection of window 1
        
set f to alias 1 of s
    
else
        
set f to file of window 1
    
end if
end tell

tell application "Finder"
    
set c to f's container as alias
    
set p to POSIX path of c
end tell

tell application "BBEdit"
    
make new shell window with properties {working directory:p}
end tell

Last Modified: 2010-11-27