Repository navigation
[feature] Place the cursor at a given place after an abbr #2287
Description
Activity
Thanks for the kind words :)
Is the idea that you want to have the cursor inside the closing quotes. That makes a lot of sense, and is something that global aliases definitely could not do. Do you have ideas for what the syntax for this could be?
Also, what would you like or expect to happen if you press return after typing the abbreviation but before it expands? Today that expands and then executes it; maybe it should just expand it.
Reacted by Pierre Spring and Jason NaderAlso, what would you like or expect to happen if you press return after typing the abbreviation but before it expands? Today that expands and then executes it; maybe it should just expand it.
If I may interject -
it's GNU/expandsI'd like it if it just executed, or if at least there was an easy way to just execute what is written on the commandline.Today, I can't see a way to execute something called
pmif I define that as an abbr forpulsemixer- or I'm just missing something.@faho that is what happens today for abbreviations, and I think everyone likes that.
But the idea here is a new mode, a sort of "abbreviation template," that expands and then puts the cursor somewhere for you to edit (in this case, presumably a table name). So the command doesn't make sense to run on its own.
Here's another (not fully formed) idea: maybe abbreviations should just be functions:
function describe --abbreviates mysql -u root my_database -e "describe $argv[1]" endand now the abbreviation itself takes an argument:
describe some_table, which expands to:mysql -u root my_database -e "describe some_table"This also would let us use tab completion with abbreviations. This means abbreviations are starting to look just like functions - well, maybe that's a good thing.
Reacted by Alexey Alekhin, dkrm, Pierre Spring, sandnuggah, Bastian Böhm, Alex Hunt and Matteo Ferrando@faho that is what happens today for abbreviations, and I think everyone likes that.
It's not.
$ abbr -s abbr pm pulsemixer $ type pm type: Could not find 'pm' $ pm #<ENTER> # launches pulsemixerHere's another (not fully formed) idea: maybe abbreviations should just be functions:
That's just what alias does, isn't it? Or do you want it do be expanded when you enter it interactively? In that case, the function would need to be parsed for a "$argv" - and how would that work with multiple occurences of it?
Instead, I'd rather have a "special token" for abbr, like
abbr describe mysql -u root my_database -e "describe @"or, considering find and xargs as prior art "{}" - though of course there's a bug about that.
If that token occurs, after expansion the cursor is placed at that position (with the token removed).
The underlying assumptions are of course that the token will be reasonably uncommon (since it would need to be masked if it were to occur) and that there isn't much more functionality to add to abbr, so it makes sense not to generalize it much more.
Hi,
Also, what would you like or expect to happen if you press return after typing the abbreviation but before it expands? Today that expands and then executes it; maybe it should just expand it.
I see it like this :
Case their is no $CURSOR (or something else) defined and user press enter
-> same behavior as nowCase their is no $CURSOR (or something else) defined and user press space
-> same behavior as nowCase their is a $CURSOR defined and user press enter
-> expand the abbrev, put cursor on $CURSOR : no surprise, no errorCase their is a $CURSOR defined and user press space
-> expand the abbrev, put cursor on $CURSOR : no surprise, no error, delete the last space added by keyboardHope this will be integrated to fish.
We plan to work with "GitFlow" git workflow and I'll set some abbreviations. But for some abbreviations, I need to place the cursor inside the command:
master=>git checkout masterdevelop=>git checkout developfeature=>git checkout -b feature-$CURSOR developrelease=>git checkout -b release-$CURSOR develophotfix=>git checkout -b hostfix-$CURSOR master
This would allow typing quickly:
feature 21-add-product-details=>git checkout -b feature-21-add-product-details developrelease 0.0.6=>git checkout -b release-0.0.6 develophotfix 12-unable-to-login=>git checkout -b hotfix-12-unable-to-login master
Reacted by Jason Nader, Takumi Kameyama, Ronan Jouchet and Richar Muñico Samaniegofishcurrently doesn't use Git Workflow. In My Humble Opinion, the pros is stable developments, the cons is that it slows down developments, forcing developers to use develop branch, master branch currently doesn't not have a lot of bugs either. If the users need stable release, they can just use a fish release.What do you think?Sorry that I replied that stupid message.
I think you didn't understand my message ^^ I never talked about Fish workflow ;)
I am sorry that I didn't understand your message. I know what you mean now. I think you can just:
feature 21-add-product-details->git checkout develop -b feature-21-add-product-detailsrelease 0.0.6->git checkout develop -b release-0.0.6
For example, abbr
featuretogit checkout develop feature-but the downside is that you need to press extra backspace. I just can't figured out how to put a backspace into the abbr, using\bdoesn't work.In addition, I think you can also create a function to just
feature 21-add-product-details.I'm also interested in creating abbreviations where you can define the final caret position. My use case is similar to what @pickfire describes above (need to get rid of the space after expanding).
Is there any progress on this?Reacted by Jason Nader, Rijnder Wever, Richar Muñico Samaniego, Jacob Chapman and ChrisIf I define an abbr like
abbr -a svnci 'svn commit -m ""', it would be enough for me to have something like a post-abbr function that moves the cursor one position to the left to end up inside the double quotes.
A caret marker saying "please let the cursor end up here" would be a bit overkill IMO.Reacted by Jason Nader and Richar Muñico SamaniegoHey @cmarqu, in the particular case of placing cursor between the quotes, you may be interested in using pisces plugin (I'm the author), then you can define your alias like
abbr -a svnci 'svn commit -m', type first quote"and it will get autoclosed with the cursor staying inside 👌For the issue in general, there is a plugin with similar functionality: oh-my-fish/plugin-expand, it's like
abbrbut more advanced (I'm not using it myself, but it seems relevant here).Reacted by nilshae, Helder S Ribeiro, Jason Nader, Razzi Abuissa and Patrick Schratzany progress on this?
Reacted by Filip Krawczyk, Vlad Terin, Steven Kalinke and Carlos Alexandro BeckerNobody is working on this AFAIK
Reacted by Carlos Alexandro Becker and Peeyush KushwahaI came across this while looking for a way to expand one of my abbreviations without having the extra whitespace added at the end. It seems that isn't possible right now, and this proposal would make that (and more) possible.
Is there an appetite for a smaller scoped "expand without whitespace" feature in lieu of this one being implemented?
Reacted by James and Rijnder WeverThis would be super useful for pasting URLs on various commands.
- are there any other ways of "auto-quoting" a pasted URL?
- what would be a good starting point to work on this from a fish outsider?
are there any other ways of "auto-quoting" a pasted URL?
Paste it inside of single-quotes:
curl 'then paste. This will escape all
'and\, so you can just close the quote after. (or close it before and move the cursor inside)Reacted by Johannes Altmanninger, Ivan Tham and David AdamIs there an appetite for a smaller scoped "expand without whitespace" feature in lieu of this one being implemented?
I would really like such an option, actually (lets denote it
-X). For example. it would be cool if you could use abbreviations to construct paths:# I sometimes need to call binaries from /usr/local/bin/ abbr -X -a -- ul /usr/local/bin/
Or to construct abbreviations for programs that require an single argument without any spaces:
# search bibliography based on either author or title abbr -X -a -- pla 'pubs list author:' abbr -X -a -- plt 'pubs list title:'
Reacted by Razzi Abuissa and Chrisabbr -X -a -- ul /usr/local/bin/
You can use a key binding, let's say Alt+AAlt+U
bind \ea\eu 'commandline -i /usr/local/bin/'Reacted by Rijnder WeverAnother use case: when using fish's
beginandendtosetenvironment variables just for the command, this feature would be useful to place the cursor beforeendIs anyone working on this, either the
-X(no whitespace) option, or the cursor movement feature? I might take a crack at it.Reacted by Saúl NoguerasReacted by Razzi Abuissa, Peeyush Kushwaha, teapot, Jan-Philip Loos, Amir Hossein Hashemi, Peter Cardenas and PaweI PrzenicznyI am not aware of anyone working on it.
Reacted by David Adamthis is now implemented by the new
abbr --set-cursorswitch from #9313Reacted by Rijnder Wever, Henry Eklind, Vyacheslav Konovalov, Max, Chris, Arad Alvand, Jens, Antoine Bertin, David Gidwani and NixaperReacted by Razzi Abuissa, Marcin Wojnarowski, Ronan Jouchet, runiq, Henry Eklind, Chris, Arad Alvand, Antoine Bertin, Alex Wall, David Gidwani and 4 moreReacted by Alex Wall, David Gidwani, Jean-Yves TOUMIT, bright and Danny Pease- locked as resolved and limited conversation to collaborators
on May 25, 2026
Hi,
I love abbreviation, it always show me the right command.
But sometimes I need to put the cursor at a given place, is it possible to do that ?
Example :
and so, after typing "describe" I would like to have my cursor at $CURSOR
Thank you for this awesome shell ;)