Comments (6)
Yes, that's exactly what I needed! Feeling stupid, didn't figure out myself!
Thanks a lot!
from zsh-abbr.
Also, a 2nd thought, we should auto sync alias
and abbr
in-case people are using both and transitioning!
from zsh-abbr.
Thanks for the idea!
alias-tips has an excludes array (https://github.com/djui/alias-tips#exclude-some-aliases). If for every abbreviation you have an alias with the same short form (for example, alias x="my command"
and abbr x="my command"
) then adding this snippet to your .zshrc
should automatically exclude all abbreviations when the shell initializes:
export ZSH_PLUGINS_ALIAS_TIPS_EXCLUDES="${(f)$(abbr l)}"
(that is, a single string from abbr l
's multi-line output). If you're already excluding things,
export ZSH_PLUGINS_ALIAS_TIPS_EXCLUDES="myalias ${(f)$(abbr l)}"
After adding a new abbreviation, open a new terminal and/or refresh open terminals (source ~/.zshrc
or, preferably, exec zsh
) to exclude the newly added abbreviation.
Does that meet your need?
from zsh-abbr.
I've chosen to not support auto syncing because it would require letting abbr write and possibly first parse .zshrc
. Have you tried abbr export-aliases
and abbr import-aliases
? See https://github.com/olets/zsh-abbr#commands for documentation.
You could do something like
-
run
abbr import-aliases
once -
add to the end of your
.zshrc
abbr export-aliases > $HOME/aliases-from-abbr source $HOME/aliases-from-abbr
Putting it at the very end of your .zshrc
will keep the aliases from breaking other parts of your shell initialization.
//
Another approach: run
abbr import-aliases
once and then delete as many aliases as possible. That's my personal recommendation. It would probably even obviate your alias-tips problem. If you decide to switch back to aliases, run abbr export-aliases
once, and copy and paste that into your shell config.
from zsh-abbr.
I understand both the workarounds you proposed!
But I wanted to suggest something different
Assuming all the aliases are present in .zsh-aliases
which is sourced in .zshrc
Someone might want to use both abbr
and alias
interchangeably.
What I suggest is
- we create a hook that runs
abbr export-aliases
to.zsh-aliases
file at session end (or on-demand) - Another hook that clears (
abbr clear-all
)abbr
and then addabbr import-aliases
Let me know if that makes sense, I can add a PR, or we can discuss in more details about the implementation!
from zsh-abbr.
Interesting idea! For now, it doesn't feel to me like syncing abbreviations and aliases is something zsh-abbr should take on — it's sort of a meta responsibility. But let's keep thinking it through.
//
abbr clear-all
Now and then I consider making a "delete all abbreviations" function… But I'm afraid if it existed I'd run it by mistake! The easiest way to roll your own will be
echo > $ABBR_USER_ABBREVIATIONS_FILE
abbr load
at session end
I'm not aware of a way to do this, but sounds cool. Are you?
//
What if you invert my previous idea, letting aliases be the source of truth
# .zshrc
source .zsh-aliases
# load zsh-abbr and then
abbr import-aliases --quiet
and to add an alias and an abbreviation use
% echo alias x=y > .zsh-aliases && exec zsh
(Could make a function for that, and abbralias x=y
.) Or am I still not seeing your use case?
from zsh-abbr.
Related Issues (20)
- `zsh-abbr` not working when the `viins` keymap is selected HOT 5
- abbr command completion
- [Bug report] bad math expression: operator expected at `Jan 1 03:...' HOT 4
- [feature] abbreviations may place the cursor anywhere in the expansion, instead of only at the end HOT 1
- [Bug report] Cannot programmatically delete abbreviations containing certain characters HOT 5
- fast-syntax-highlighting highlighting of multi-word abbreviations
- [Bug report] Terminal "freezes" when there is no abbreviations and highlights for user abbreviations are used with zsh-syntax-highlighting HOT 4
- Using zi/zinit's `sbin'**/eza -> ls'` to replace `ls` with `eza` breaks zsh-abbr initialization HOT 4
- [Feature] Prefixes 1/n: Ignored string prefixes
- [Feature] Prefixes 2/n: Ignored glob prefixes
- [Feature] Prefixes 3/n: linear combinations of prefixes
- [Bug] unexpected behavior when `ABBR_EXPANSION_CURSOR_MARKER` set to caret HOT 3
- acknowledge committers
- allcontributors 1/ HOT 2
- acknowledge bug reporters HOT 1
- `!` is escaped in v5, but wasn’t in v4 HOT 12
- `abbr c` does not clear abbreviations created with the pattern `abbr x=y` HOT 3
- Teach `add` about `--force`
- [Bug report] involuntary history filtering possible in combination with zsh-autosuggestions and v5.x HOT 11
- Conflict warning logged in all new sessions when adding an abbreviation in zshrc HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zsh-abbr.