On Sep 20, 2015, at 21:27, Fabio Grazioso <[email protected]> wrote:
> I am a new BBEdit user, with a long experience as TextWrangler (TW) user.
> In TW I am used at running python scripts with the command "Run in Terminal",
> and in TW the default behaviour is to save the file before sending it to the
> terminal.
______________________________________________________________________
Hey Fabio,
If I'm not mistaken that behavior is dead and gone in BBEdit. I believe all
windows (saved or not) when 'Run in Terminal' are run from a temporary file.
(The guys will correct me if I'm wrong.)
To double-check I skimmed the manual and the expert settings and didn't find
any options for this.
In any case you can roll-your-own.
The appended script will error if the front document is unsaved, otherwise it
will run the document from the directory it's in.
The front Terminal window will be used if it isn't busy, otherwise a new
Terminal window will be opened and used.
--
Best Regards,
Chris
-------------------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2015/09/22 11:00
# dMod: 2015/09/22 11:21
# Appl: BBEdit, Terminal
# Task: Attempt to run the front text document in Terminal.app.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @Run, @Front, @Document, @Terminal
-------------------------------------------------------------------------------------------
tell application "BBEdit"
tell front text document
if on disk = false then error "Front document is not saved!"
if modified = true then save
if contents of line 1 does not start with "#!" then error "No valid shebang
line found!"
set docName to its name
set docFile to POSIX path of (get its file)
end tell
end tell
set shCMD to text 2 thru -1 of "
FILE=" & docFile & ";
if [[ ! -x \"$FILE\" ]]; then
chmod +x \"$FILE\";
fi
"
do shell script shCMD
set {oldTIDS, AppleScript's text item delimiters} to {AppleScript's text item
delimiters, "/"}
set docName to quoted form of docName
set docParentPath to quoted form of ((text items 1 thru -2 of docFile) as text)
set AppleScript's text item delimiters to oldTIDS
tell application "Terminal"
activate
if name of windows = {missing value} then do script
if processes of front window = {} then do script
tell front window
if its busy = true then
do script "cd " & docParentPath & " && ./" & docName
else
do script "cd " & docParentPath & " && ./" & docName in selected tab
end if
end tell
end tell
-------------------------------------------------------------------------------------------
--
This is the BBEdit Talk public discussion group. If you have a
feature request or would like to report a problem, please email
"[email protected]" 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 [email protected].
To post to this group, send email to [email protected].