-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add guide to register macOS substitutions #37
Conversation
By the way, substitutions containing newlines and other special characters seem to be escaped properly. |
Regarding performance, is there a reason why your This is how I load the plugin and register the substitutions without any impact to shell startup time: _register_mac_text_substitutions() {
for substitution in ${(@f)"$(defaults read ~/Library/Preferences/.GlobalPreferences.plist NSUserDictionaryReplacementItems | plutil -convert json -o - - | jq -r "map({ (.replace): .with}) | add | to_entries|map(\"\(.key)=\(.value|tostring)\")|.[]")"}; do
abbr add --session --global --quiet "$substitution"
done
}
zinit ice wait lucid atload'_register_mac_text_replacements'
zinit light olets/zsh-abbr |
Sorry for the long silence @mortenscheel! Two ideas for changes:
I don't use turbo mode for this plugin just in case something is slow. I don't want to open a new terminal, type some commands, then look at the window and see abbreviations! (And in the Performance section I don't use it because I want to show that even the slowest possibility is not slow.) But there's nothing wrong with using turbo mode. If it works for you that's great |
No problem :) I've also replaced the options with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your patience. One inline question. I've also started wondering… should this be in the readme or should it be supported, just like importing aliases? What do you think?
|
||
```shell | ||
for substitution in ${(f)"$(defaults read ~/Library/Preferences/.GlobalPreferences.plist NSUserDictionaryReplacementItems | plutil -convert json -o - - | jq -r 'to_entries[] | "\(.value.replace)=\(.value.with)"')"}; do | ||
abbr add [options] "$substitution" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work?
abbr add [options] "$substitution" | |
abbr add [options] $substitution |
There may be an edge case I'm not thinking of.
Sorry, I missed your comment. I don't have a clue how many people will find this feature useful. Maybe just put it in the readme, and see if anyone asks for a command to import them? |
@mortenscheel this is in |
@all-contributors please add @mortenscheel for code. (#37) |
I've put up a pull request to add @mortenscheel! 🎉 |
I've tried my best to implement the suggestions mentioned in #35 but you're welcome to suggest further changes.