On May 23, 2013, at 10:18, Jeremy Cowgar <jer...@cowgar.com> wrote: > When using the content menu on a given directory, it defaults to the selected > directory. If a keyboard shortcut existed, I would think it would default to > the project directory. If I wanted to place the file in a sub-directory of > the project, I could navigate there.
______________________________________________________________________ Hey Jeremy, This is doable. The script presents you with a save-dialog and lets you choose a location and file name. The default name is "New-File.txt", but you can change that to anything you want. The dialog opens with a default location of the .bbprojectd file of the front project, but you can go anywhere from there. The new file is created in the project and is added to the file panel. There are two versions of the script. The second one works around Default Folder if it is installed. -- Best Regards, Chris ------------------------------------------------------------------------------------------- try set AppleScript's text item delimiters to ":" tell application "BBEdit" if front window's name ends with ".bbprojectd" then set _proj to a reference to the front project document tell _proj to set projRootFldr to (text items 1 thru -3 of (its file as text) as text) & ":" set _file to choose file name default location (projRootFldr as alias) default name "New-File.txt" set newDoc to make new text document at _proj's window initial save location _file tell newDoc to save tell _proj to make new project item with properties {file:_file} else error "Front window is not a project document!" end if end tell on error e number n if n ≠ -128 then set e to e & return & return & "Num: " & n tell me to set dDlg to display dialog e with title "ERROR!" buttons {"Cancel", "Copy", "OK"} default button "OK" if button returned of dDlg = "Copy" then set the clipboard to e end if end try ------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------- # Works around Default Folder if it is installed: ------------------------------------------------------------------------------------------- try set AppleScript's text item delimiters to ":" tell application "BBEdit" if front window's name ends with ".bbprojectd" then set _proj to a reference to the front project document tell _proj to set projRootFldr to (text items 1 thru -3 of (its file as text) as text) & ":" if dfFlag() of me then dfDisable() of me set _file to choose file name default location (projRootFldr as alias) default name "New-File.txt" dfEnable() of me else set _file to choose file name default location (projRootFldr as alias) default name "New-File.txt" end if set newDoc to make new text document at _proj's window initial save location _file tell newDoc to save tell _proj to make new project item with properties {file:_file} else error "Front window is not a project document!" end if end tell on error e number n if n = -128 then dfEnable() of me else set e to e & return & return & "Num: " & n tell me to set dDlg to display dialog e with title "ERROR!" buttons {"Cancel", "Copy", "OK"} default button "OK" if button returned of dDlg = "Copy" then set the clipboard to e end if end try ------------------------------------------------------------------------------------------- on dfEnable() tell application "Default Folder X Helper" Enable end tell end dfEnable ------------------------------------------------------------------------------------------- on dfDisable() tell application "Default Folder X Helper" Disable end tell end dfDisable ------------------------------------------------------------------------------------------- on dfFlag() try set dfPrefPane to ((path to system preferences from user domain as text) & "Default Folder X.prefPane:") alias dfPrefPane set cmd to " ps xc | sed -En 's!.+(Default Folder X Agent).*!\\1!p'" set _flag to do shell script cmd if _flag = "Default Folder X Agent" then return true end if on error return false end try end dfFlag ------------------------------------------------------------------------------------------- -- This is the BBEdit Talk public discussion group. If you have a feature request or would like to report a problem, please email "supp...@barebones.com" rather than posting to the group. Follow @bbedit on Twitter: <http://www.twitter.com/bbedit> --- You received this message because you are subscribed to the Google Groups "BBEdit Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+unsubscr...@googlegroups.com. To post to this group, send email to bbedit@googlegroups.com.