Mark certain commands to allow expansion of regular abbreviations following them #99
Replies: 3 comments
-
Interesting idea, thanks for the suggestion. The way to support this that comes to mind is an array of strings to ignore at the front of the buffer. Default empty array. Call it "command expansion ignored prefixes" or something like that. Loop over the array, trimming at most one of those strings off the front of the buffer and then continuing out of the loop. Haven't yet spent the time to think about the "can be done but should it?" question. //
Enhancing zsh-abbr is a low priority for me currently, so I wonder if we can come up with a solution for your need that doesn't require zsh-abbr enhancement. I don't know your workflows of course, but on the surface it looks like you could abbr -g "k gp"="kubectl get pods" and get the echo example to work with echo k gp; or abbr -g k=kubectl
abbr -g "kubectl gp"="kubectl get pods" and then echo k<ctrl space>gp |
Beta Was this translation helpful? Give feedback.
-
Yeah I have a solution that is sufficient for now. I have a section in my dotfiles that automatically sets up certain abbreviations on startup (it's kind of silly since I can just stick my abbreviations file directly in my dotfiles, but I'll do that some other day lol). I have added this part to it to iterate over all my desired abbreviations and create variations of them prefixed with |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Certain shell commands, such as
sudo
orwatch
, are typically immediately followed by a full shell command. One might conceptualise them not as commands in their own right, but more as modifiers to commands. I don't for example think ofsudo apt install
as a separate command toapt install
, but rather as applyingsudo
as a modifier toapt install
.I would like to be able to indicate to zsh-abbr that a given command is to be understood as preceding a full command, and thus that any regular (non-global) abbreviations must be expanded after that command.
So if I have
k gp
as an abbreviation ofkubectl get pods
, and I marksudo
andwatch
as "modifier commands", then:watch k gp
should expand towatch kubectl get pods
;sudo k gp
should expand tosudo kubectl get pods
;echo k gp
should not expand to anything.This behaviour is possible with great manual effort, but it would be a lot more convenient if zsh-abbr supported it directly as a feature.
Beta Was this translation helpful? Give feedback.
All reactions