On Nov 11, 2015, at 14:32, TJ Luoma <luo...@gmail.com> wrote: > BUT THEN I decided that I wanted it to automatically save, but that never > seemed to work _until_ I got a little sneaky. > > I used `zsh's` ability to fork and abandon a sub-shell using ( this ) &| ______________________________________________________________________
Hey TJ, Interesting. I wonder if that can be done in Bash 4.x. > PATH=/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin Not necessary for normal usr commands. > cat "$@" | sed 's# *$##; s# *$##' BBEdit provides the file internally for the given command, so cat is not needed. #!/bin/zsh read -r -d '' bbeditScript <<'EOF' tell application "BBEdit" tell front document if on disk = true then tell it to save end if end tell end tell EOF sed -E 's![[:blank:]]+$!!'; osascript -e "$bbeditScript" &| > The only downside seems to be that the cursor/insertion point moves when it > runs. I don't know how to avoid that. IF anyone else does, or has a better > way of doing this, please let me know. Look at the environment variables on p. 318 of the BBEdit user manual. You can discover a number of things about the selection and restore it using the same AppleScript you save the document with. Or you can go pure AppleScript which will not affect the selection. tell application "BBEdit" tell front text document tell its text to replace "[[:blank:]]+$" using "" options {search mode:grep, starting at top:true} if its on disk = true then save it end tell end tell -- Best Regards, Chris -- 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.