9

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;
    app.chooseFile().toString();"

Thanks for any help.,

2

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;
    app.chooseFile().toString();"

… will at least give you keyboard control.

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

You must log in to answer this question.

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