Running a command line tool based on its extension
-
16-10-2019 - |
Pergunta
I use Leo for structured editing of my code, and Leo has the extension of .leo.
In order to run Leo, I use the following alias
alias leo='arch -x86_64 /usr/bin/python2.6 /Users/bin/Leo-4.7.1-final/launchLeo.py --gui=qt'
It works well to launch leo with leo file as follows.
leo -f hello.leo
However, I need to find a way to launch Leo by clicking the leo file in the Finder/Path Finder.
What might be the solution to this problem?
ADDED
Mankoff's advice on using Automator works. For running PyQt with -f option, I set "Pass input : as argument", and have the following bash code, which launches with/without -f option depending a file is dragged on or not.
if [ -z $1 ]
then
arch -x86_64 /usr/bin/python2.6 /Users/smcho/smcho/bin/Leo-4.8-b1/launchLeo.py --gui=qt
else
arch -x86_64 /usr/bin/python2.6 /Users/smcho/smcho/bin/Leo-4.8-b1/launchLeo.py --gui=qt -f $1
fi
Solução
I would use Automator. Make an app that takes an argument (file dropped on it, file double-clicked associated with that app, whatever), and runs the command you have above.
Outras dicas
- Right click on a .leo file and select Get Info
- On the [whatever.leo] info pane that opens, use the Open With drop-down to browse to the Leo editor.
- Click the Change All... button
Double clicking any .leo file should invoke the Leo editor from now on.