Subscribe to
Posts
Comments
NSLog(); Header Image

My Favorite BBEdit Script

This script, in combination with FTPeel's Magic Mirror feature, comes in quite handy:

set filepath to ""
tell application "BBEdit"
    save front document
    set filepath to file of front document
end tell
tell application "FTPeel"
    open filepath
end tell

I've saved it as shift-command-S (which BBEdit uses as "Save to FTP Server" anyway).

Update for BBEdit 8:

set filepath to ""
tell application "BBEdit"
    set thisFile to (active document of front window)
    save thisFile
    set filepath to file of thisFile
end tell
tell application "FTPeel"
    open filepath
end tell

8 Responses to "My Favorite BBEdit Script"

  1. Unless you know something I don't, the first line (where you initially set `filepath`) isn't necessary.

  2. Hello 🙂

    Now, this could rule if it worked with VIM :-/

    But it does not - since VIM does not have support for AppleScript.

    Anyway, since you are a FTPeel developer: Could it be possible to make a support for VIM? It's like the best editor - but no Mac FTP applications support it.

    And it's actually sad - because VIM already has support for FTP (and other protocols). The only thing that FTPeel need to do is to send this to vim ftp://[user@]machine[[:#%5Dportnumber%5D/path - and it will handle the rest.

    Well, since I am not a Mac developer - - I don't have a clue how to send this information to VIM (but it should not be that hard, since VIM is already well integrated in Panther)

    If you need info, check this out:

    http://www.vim.org/htmldoc/pi_netrw.html

    Kind regards,

    Amir

  3. Amir,

    I think you should be able to do all this with a vim script. Something like

    :w

    :!osascript -e "tell application \"FTPeel\" to open foo"

    "not sure how to to the filename into foo ...

    Somehow I doubt it is very practical to add extensive Applescript support to (Carbon) Vim, although some sort of do script command would be nice so that you could write the Vim script and then call it from Applescript.

  4. Hello and thanks for your answer.

    It's actually pretty damn cool that you can use AppleScript from the prompt!

    I didn't knew that.. God damn - I am going to make some wild VIM scripts now!

    Well, I will now buy FTPeel - because this feature simply rocks!

    Anyway, for any users that use VIM here is what to do. In your .vimrc file put this function:

    " FTPeel

    fun! MagicMirrorIt()

    let path = substitute(expand("%:p"), '/', ":", "g")

    let nice_path = substitute(path, "^:", "", "")

    execute('!osascript -e "tell application \"FTPeel\" to open \"' . nice_path . '\""')

    endfun

    map :call MagicMirrorIt()

    I think I actually found a bug - - but I fixed it manually. When you paste a normal UNIX path to FTPeel - - it does not fully convert it to a "mac path". If I send /path/blah/blah/file.ext then FTPeel converts it to /path:blah:blah:file.ext (Where the first / should not be there - and therefore it can't find the file).

    But anyway, when you want to paste a file to FTPeel - - you simple hit your leader hotkey + space - and Kamboom - It gets uploaded on the web. Wow, if this isn't smart - - then I really don't know what is!

    I mean I used to open some lame FTP client - Connect. Find my file on my local computer. Then the same file on my server and then first upload it. Now, I simply hit one hotkey . . Amazing!

  5. Hey again

    I have just uploaded this tip to Vim.org.

    Expect costumers - - VIM is actually pretty popular on Mac.

    Click to see my tip

    Kind regards,

    Amir

  6. rentzsch,

    I just happened to remember the need for the first "set filepath." Applescript seems to scope variables to the outermost block where they're defined. So, if the filepath were defined as such

    tell Application "BBEdit"

    set filepath to ...

    ... and more

    heck, maybe use filepath a few times in here

    end tell

    filepath doesn't work here

    tell application "FTPeel"

    filepath also doesn't work here

    end tell

    The first set filepath statement effectively gives filepath a global scope. You could achieve the same result with the global statement, I suppose.

  7. BBEdit 8 is now available. I'll amend this post later with thoughts. The multi-document-in-one-window idea looks good, though. What's new? Text Factories look good - but I'll have to get into them. I work on so many different kinds of...

  8. I've finally gotten around to updating my favorite AppleScript for BBEdit so that it works properly with BBEdit 8's "tabbed" windows: set filepath to "" tell application "BBEdit"     set thisFile to (active document of front window)...


Comments RSS

Leave a Reply


Warning: Undefined variable $user_ID in /var/www/vhosts/nslog.com/httpsdocs/wp-content/themes/nslog/comments.php on line 96

Please abide by the comment policy. Valid HTML includes: <blockquote><p>, <em>, <strong>, <ul>, <ol>, and <a href>. Please use the "Quote Me" functionality to quote comments.