EditorKicker.app is a small macOS application to handle texteditor://
URL schema.
This application invokes any your favorite editor when you clicked 'texteditor://'
URL (for example texteditor://open?url=file://&line= ) in your browser.
This is very useful for web application development as you can open and edit program files in your favorite editor with just one click in your browser.
EditorKicker.app is implemented in AppleScript and shell script, therefore it will work on any macOS version and any CPU architecture.
- Download zip file from download page and unzip it.
- Control-click (or Right-click)
Setup.command
script and select 'Open'. Confirmation dialog will be displayed, then click 'Open' button. - Move EditorKicker.app to '/Applications' folder.
- Double click EditorKicker.app under '/Applications' folder.
This will generates
$HOME/.config/EditorKicker/command
file. - Open
$HOME/.config/EditorKicker/command
file and edit it to select text editor command. - Install command line tool of your favorite editor. See the next section for details.
- Run
open texteditor://open?url=file://<filepath>&line=<number>
in Terminal.app and confirm that your favorite text editor will open the file. For example,open texteditor://open?url=file:///Applications/EditorKicker.app/README.md&line=21
.
To use EditorKicker.app, you must install command line tool of your favorite
text editor into /usr/local/bin
.
For example, if you like VS Code, you must install /usr/local/bin/code
command.
The following sections show how to install command line tool for each text editor.
See: https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line
Or:
[Terminal]$ sudo ln -s "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code" /usr/local/bin/
[Terminal]$ which code
/usr/local/bin/code
- Menu: TextMate > Settings...
- Select 'Terminal' icon tab.
- Press 'Install' button.
Or:
[Terminal]$ sudo ln -s "/Applications/TextMate.app/Contents/MacOS/mate" /usr/local/bin/
[Terminal]$ which mate
/usr/local/bin/mate
See: https://www.sublimetext.com/docs/command_line.html#mac
Or:
[Terminal]$ sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/
[Terminal]$ which subl
/usr/local/bin/subl
See: https://www.jetbrains.com/help/pycharm/working-with-the-ide-features-from-command-line.html
Or:
[Terminal]$ sudo ln -s "/Applications/PyCharm CE.app/Contents/MacOS/pycharm" /usr/local/bin/
[Terminal]$ which pycharm
/usr/local/bin/pycharm
[Terminal]$ sudo ln -s "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient" /usr/local/bin/
[Terminal]$ sudo ln -s "/Applications/MacVim.app/Contents/bin/mvim" /usr/local/bin/
[Terminal]$ which mvim
/usr/local/bin/mvim
See: https://coteditor.com/cot
Or:
[Terminal]$ sudo ln -s "/Applications/CotEditor.app/Contents/SharedSupport/bin/cot" /usr/local/bin/
[Terminal]$ which cot
/usr/local/bin/cot
- Menu: Zed > Install CLI
Or:
[Terminal]$ sudo ln -s "/Applications/Zed.app/Contents/MacOS/cli" /usr/local/bin/zed
[Terminal]$ which zed
/usr/local/bin/zed
EditorKicker.app supports the following URL format.
texteditor://<filepath>?line=<number>
texteditor://open?file=<filepath>&line=<number>
texteditor://open?url=file://<filepath>&line=<number>
Examples:
- texteditor:///Applications/EditorKicker.app/README.md?line=21
- texteditor://open?file=/Applications/EditorKicker.app/README.md&line=21
- texteditor://open?url=file:///Applications/EditorKicker.app/README.md&line=21
EmacsKicker.app just runs shell script
/Applications/EmacsKicker.app/Contents/SharedSupport/bin/emacskicker
.
You can customize this script as you like.
- In Finder: 'Applications' > 'Utilities' > 'Script Editor.app'.
- Menu: 'File' > 'New...'
- Write the AppleScript program to invoke shell script (see below).
- Menu: 'File' > 'Save...'. Enter 'Name', select 'File format' as 'Application', and press 'Save' button.
- Create shell script
<YourApp>.app/Contents/SharedSupport/bin/<script>
and make it executable bychmod
command. - Edit
<YourApp>.app/Contents/Info.plist
and register custom URL schema (see below). - Copy '.app' to 'Applications' folder.
AppleScript:
--
-- please replace '<script>' with your script name
--
on open location input
set appdir to POSIX path of (path to current application) as string
set scriptfile to appdir & "/Contents/SharedSupport/bin/<script>"
do shell script scriptfile & " " & (quoted form of input)
end open location
Shell script:
#!/bin/sh
set -eu
if [ $# = 0 ]; then
echo "Usage: <script> foobar://open?url=file://<file>&line=<number>"
exit 1
fi
link="$1"
file=$(echo $link | sed -E 's/foobar:\/\/open\?url=file:\/\/([^&]+)&.*/\1/')
line=$(echo $link | sed -E 's/foobar:\/\/open\?[^&]+&line=([0-9]+).*/\1/')
code -g "$file:$line" # VS Code (for example)
Make the script executable:
[bash]$ chmod +x <YourApp>.app/Contents/SharedSupport/bin/<script>
Info.plit: (add the following to the top of <dict>
)
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>YourApp URL</string>
<key>CFBundleURLSchemes</key>
<array>
<string>foobar</string>
</array>
</dict>
</array>