BBEdit Disk Browser and Terminal Scripts
In the previous post, I mentioned BBEdit’s disk browsers. These are one of my favorite features, but many BBEdit users don’t seem to use them. This is how I use them. Much of what I do revolves around three basic activities:
- Finding a file to work on.
- Viewing or editing the file, usually in BBEdit, Interface Builder, Safari, or Photoshop.
- Running shell commands on the file or its relatives.
It’s essential that I be able to move from one activity to another quickly. Disk browsers combined with some AppleScripts make it convenient for me to use BBEdit as the hub. I can almost everything without using Xcode or the Finder.
To view files, or pick one to work on, I use disk browsers. They’re much faster than the Finder (or Path Finder, which I use when I need to move or copy files) to move up and down levels and peek at the contents of files or folders.
To edit a file in a disk browser, I select it (usually by typing the first few letters of its name) and press Return. This opens it for editing in BBEdit. Pressing Option-Return opens it in the default application, instead of BBEdit. Thus, if I have an HTML file I can press Return to edit it, or Option-Return to preview it in Safari. Or, if I have a package, I can press Return to treat it as a folder and view its contents in the disk browser, or Option-Return to open it as a package.
When I’m editing a file, I might want to view its parent folder or one of its siblings. Running this script opens a new disk browser window that makes it easy to do this.
Or, I may want to run shell commands on the file that I’m editing or on one of its relatives that I’m viewing in a disk browser. To do that, I run a script to open a shell worksheet or Terminal window with the proper working directory.
When I’m in a shell, I can use the bbedit tool to get back to an editing window (if I give it a file) or disk browser (if I give it a folder).