I'd like to open the native file browsing dialog from the command line, focus the dialog, and then get the full path of the selected file.

The following works nicely, but the dialog is not focused and therefore can't be controlled via the keyboard:

osascript -l JavaScript -e "var app = Application.currentApplication();
    app.includeStandardAdditions = true;

Thanks for any help.,

  • 3
    Interesting question!
    – nohillside
    Oct 15, 2018 at 9:55

1 Answer 1


I have some Karabiner-EventViewer experience and found out that your "currentApplication()" is not Terminal, as one would think, but actually osascript.

Therefore …

osascript -l JavaScript -e "var app = Application(\"Terminal\");
    app.includeStandardAdditions = true;

… will at least give you keyboard control.

  • Amazing, thank you :) Now writing mails with attachments in vim is much more fun!
    – sudoremo
    Nov 7, 2018 at 9:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .