-
Notifications
You must be signed in to change notification settings - Fork 20
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
Abbreviations not expanded after (( or $( #9
Comments
Hi @olets , sad to see this 🙁. I was about to create an issue for this. Is there any hack/workaround? |
What's your use case? |
Basically, doing something like this: my_var=$( echo <alias-i-want-to-expand> .... ) |
What is the |
Ah OK, sorry, I didn't think those are relevant 😛 More concrete example: I have set up something like queues=$( aws <i-want-to-exapnd-'prof'-here> sqs list-queues ) Or, basically expand it "anywhere": queues=$( aws sqs list-queues <i-want-to-exapnd-'prof'-here> ) My personal solution was to use ZSH global aliases ( |
Ok cool some ideas… Doesn't look like you really need the % abbr -g q='$(aws sqs list-queues profile=my_profile)'
% foo q # q expands (Can always keep the You don't say what context you're using % abbr -g q='aws sqs list-queues profile=my_profile'
% q | foo # q expands You could even bind There are a few plugins that add "suggestions from command history" and "search command history by any word in the command". Those will be helpful here. (I currently use zsh-history-substring-search and zsh-autosuggestions.) With that set up you might even find that you don't need an abbreviation or alias! % foo $(aws sqs list-queues profile=my_profile) bar
% foo # zsh-autosuggestions or another history suggestion plugin will suggest 'foo $(aws sqs list-queries profile=my_profile) bar'
% bar
% foo # zsh-history-substring-search's history-substring-search-up key, or some other plugin, will take you to 'foo $(aws sqs list-queries profile=my_profile) bar'
% bar # zsh-history-substring-search's history-substring-search-up key, or some other plugin, will fairly quickly take you to 'foo $(aws sqs list-queries profile=my_profile) bar'
% sqs # zsh-history-substring-search's history-substring-search-up key, or some other plugin, will take you to 'foo $(aws sqs list-queries profile=my_profile) bar' Another option is a function, especially if you need to run this AWS command with a variety of profiles. # in zshrc
lq() {
if (( $# )); then
aws sqs list-queues profile=$1
return
fi
aws sqs list-queues
} % lq my_profile
% foo $(lq my_profile) bar But my preference is to not use functions for small things like this, for the same reasons that I prefer abbreviations to aliases: I wouldn't want to forget the AWS command. Saving keystrokes is a high priority for me, but so is knowing the tools. I reserve functions for more complex things. Hopefully there's a solution somewhere in those ideas! -- edit: Depending on your reason for wanting an abbreviation for just the # in zshrc
AWS_PROFILE=my_profile % abbr -g q='aws sqs list-queues profile=$AWS_PROFILE'
% q[Enter]
% AWS_PROFILE=other_profile q[Enter] # q expands
# and even
% abbr o="AWS_PROFILE=other_profile"
% o q[Enter] # o and q expand I personally prefer static abbreviations, but I know some people do dynamic abbreviations like that. |
Wow, thank you @olets , that's so much to take in, I need to go through each and see which one is good for my use case But, sadly, I mistyped the first command 😛 So, the proper way to pass I also have a So, in an ideal world, I would have a single abbreviation to expand
One thing that could be a blocker with your solution(s) (I quickly went through them, so maybe I'm mistaken) is that, as you probably, know, there are a million permutations for running different This "golden" abbreviation that I'm looking for is to modify a command with as few keystrokes as possible 🙂 |
This is due to how zsh parses strings containing
((
.wontfix
because I'm okay living with this,help wanted
because ideas are welcome. I do want to rely on zsh's shell grammar parsing and word splitting (retreating to pre-a3c00f5 is not a solution).The text was updated successfully, but these errors were encountered: