Closed jgrasser closed 6 years ago
@jgrasser Ok, this totally works for me in terms of setting the shortcut. The only issue I ran into was that it doesn't take affect right away. After running the install script, hitting ctrl+cmd+v
doesn't do anything. If I restart finder, then everything works great.
I think maybe sticking a killall Finder
after may do the trick (since finder restarts automatically)? Let me mess around with it and I'll get back to you.
I can't seem to get the shortcut to work right away. If I manually restart finder (select, cmd+q, select again), the shortcut starts working. If I try to restart finder programmatically however, it doesn't seem to work.
Here's what I've tried so far...
killall Finder
osascript -e "tell application \"Finder\" to quit"
osascript -e "tell application \"Finder\" to activate"
Any ideas?
@cknadler I think you've hit on the right idea.
Below I've linked an article that details how the user defaults system works. They claim that using the defaults command will update the cache immediately. That does not appear to be true in macOS High Sierra version 10.13.3. I don't have a solution as of yet, but I think there is value in documenting what didn't work.
None of these methods resulted in the immediate update to the system defaults:
I played around with the System Preferences method of setting the hotkey and noticed that a macvim process was running in the background. Whether or not System Preferences spawns the process is unknown to me, but I've found via experimentation that starting macvim after installation causes the hotkey config to be loaded. So, I have modified the installation script to run vim-anywhere before exiting.
At this time, macvim opens a blank file. You can modify this to open the readme or some other file.
@cknadler let me know if this works on your side.
Thanks so much for digging into this! Just ran it.
Installing vim-anywhere...
Cloning into '/Users/kndlrc/.vim-anywhere'...
remote: Counting objects: 378, done.
remote: Compressing objects: 100% (15/15), done.
remote: Total 378 (delta 9), reused 18 (delta 7), pack-reused 356
Receiving objects: 100% (378/378), 281.71 KiB | 0 bytes/s, done.
Resolving deltas: 100% (196/196), done.
bash: line 143: ./bin/run: No such file or directory
I think maybe there is a relative path issue? Debugging now.
You are correct - when I tested the install script I was in the vim-anywhere directory.
No worries. I did some digging around too and it seems like you can focus any application (just by clicking on it) and the shortcut starts to work? I'm going to try seeing if simply focusing finder without restarting it makes this work as well. Otherwise, I'm fine with just opening the readme.
Cool, I was able to replicate your findings.
defaults write pbs NSServicesStatus '{
"(null) - VimAnywhere - runWorkflowAsService" = {
"key_equivalent" = "@^v";
};
"org.vim.MacVim - MacVim/New MacVim Buffer With Selection - openSelection" = {
"key_equivalent" = "@^v";
};
}'
osascript -e "activate application \"Finder\""
Awesome! I just threw this together and it works great for me. Mind testing it as well? If it works for you and you update your PR, I'll merge it in right away!
Hmm.. the it doesn't look like selected text is making it's way into the buffer.
Did that ever work? On mainline I believe vim-anywhere just opens a blank MacVim session. Do you mean text isn't making it's way in initially from keyboard shortcut -> MacVim or when closing MacVim from MacVim -> paste buffer?
The first one, test from keyboard short does not make it's way into MacVim. If that is expected behavior, then I will clean a few things up in the pr.
Yeah, thats expected behavior. There are PRs open that add that functionality, but nothing has been merged.
Also, huge thanks for figuring this out. This was the biggest open issue I've wanted to close by far.
Ok, I cleaned up the PR. When you're ready feel free to merge it in.
As part of the "clean up" I migrated the defaults settings to a plist file. I regretted doing that and quickly undid those changes. Anyways, PR is now truly ready for merge.
Awesome, merging. Thanks again!
Hey Joseph,
Thanks so much for the PR! I'm super excited to try this one out, I never was able to get my attempts to work. I'll get back to you shortly once I test it.