
Command-line doesn’t work if Kod.app is moved
Reported by Nate Silva | December 24th, 2010 @ 02:30 AM | in 0.0.3
What I did:
The first time I ran the Kod beta, it was still in my Downloads folder. It prompted me to create the link /usr/local/bin/kod.
Later, I decided I liked Kod and moved it to my Applications folder. The link stopped working.
Suggestion:
Copy the utility into /usr/local/bin/kod, rather than making it a link into the app bundle. In addition the utility should be smart enough to locate Kod.app if it’s been moved.
Comments and changes to this ticket
-
Nate Silva December 24th, 2010 @ 05:07 AM
You are correct: the utility is a symlink, but not to the main Kod.app executable, it’s a symlink to a separate executable within the Kod.app bundle.
With regard to making the utility “smart,” there are two approaches that I can think of.
(1) The first, used by BBEdit, is to copy the utility to /usr/local/bin. The bbedit command-line utility is not a symlink into the app bundle. And this command-line utility is smart enough to find the BBEdit app even if you move the app.
(2) The second approach, used by TextMate, is for the utility to be a symlink into the app bundle (just like with Kod). However, if you move TextMate, the next time TextMate is started it will notice. A dialog appears that offers to update the symlink for you.
Either would work, though the first approach (“smart” separate utility, as in BBEdit) is more robust, as the command-line utility never fails to work. The second approach (symlink that can be updated, as in TextMate) is better than what Kod has today, but the command-line utility will stop working if you move the app, until the app prompts you to update the symlink.
-
rsms December 24th, 2010 @ 04:34 PM
- Milestone set to 0.0.2
- State changed from new to open
- Assigned user set to rsms
- Tag set to helper, ux
- Milestone order changed from 15 to 0
Thanks for the write up Nate.
Alternative (1) poses a small but irritating problem: updating the helper will require super user authorization, which IMHO should be avoided if possible.
Alternative (2) is something I've planned, but maybe there's a third solution:
(3) the utility is a symlink to /Library/Application Support/Kod/kod which in turn is a symlink to the actual utility program. This way Kod.app can update the symlink in Application Support w/o requiring "sudo", but only for users in the administrator group (which should cover 99.9% of all Kod users :). However, the downside being "clutter" in /Library.
-
Nate Silva December 24th, 2010 @ 06:57 PM
Is there a command-line equivalent of this:
[[NSWorkspace sharedWorkspace] launchApplication:@"Kod"];
or this:
[[NSWorkspace sharedWorkspace] openFile:@"file.txt" withApplication:@"Kod"];
In other words, let
NSWorkspace
or Launch Services find the app. This works even if the app was moved.I don’t know if it’s available from a command-line app. I was actually able to do this from a command-line app that linked against AppKit, but I don’t know if that’s kosher.
-
Nate Silva December 24th, 2010 @ 08:03 PM
There is also the naive shell-script approach:
#!/bin/sh if [[ -t 0 ]]; then open -a Kod $* else # stdout is not a terminal (so pipe it) TEMPFILE=$(mktemp -t kod) while read data; do echo ${data} >> ${TEMPFILE} done open -a Kod ${TEMPFILE} fi
This also finds Kod automatically and doesn’t require the helper to ever be updated.
Regards,
Nate -
rsms December 26th, 2010 @ 06:55 PM
- Milestone changed from 0.0.2 to 0.0.3
- Milestone order changed from 7 to 0
-
rsms December 31st, 2010 @ 04:37 PM
- Tag changed from helper, ux to cli, helper, ux
- Milestone order changed from 9 to 0
-
rsms January 10th, 2011 @ 01:16 AM
- State changed from open to resolved
- Milestone order changed from 5 to 0
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
A text editor for Mac OS X