Trying for infix bash completionCreate bash completion script to autocomplete paths after is-equal sign?Bash...
A+ rating still unsecure by Google Chrome's opinion
Are there any OR challenges that are similar to kaggle's competitions?
Can I use images from my published papers in my thesis without copyright infringment?
Meaning and structure of headline "Hair it is: A List of ..."
What if a restaurant suddenly cannot accept credit cards, and the customer has no cash?
Alignement of different align environment
When does The Truman Show take place?
Adding things to bunches of things vs multiplication
Airline power sockets shut down when I plug my computer in. How can I avoid that?
Is it alright to say good afternoon Sirs and Madams in a panel interview?
If it isn't [someone's name]!
How do I answer an interview question about how to handle a hard deadline I won't be able to meet?
Polar contour plot in Mathematica?
C++ Least cost swapping 2
Can anybody tell me who this Pokemon is?
Why don't modern jet engines use forced exhaust mixing?
What's a good pattern to calculate a variable only when it is used the first time?
Will some rockets really collapse under their own weight?
Subgroup generated by a subgroup and a conjugate of it
Get file name and directory in .vimrc file
Unconventional examples of mathematical modelling
global variant of csname…endcsname
How to render "have ideas above his station" into German
Combinatorial Argument for Exponential and Logarithmic Function Being Inverse
Trying for infix bash completion
Create bash completion script to autocomplete paths after is-equal sign?Bash completion throwing syntax errorBash autocomplete with vim commandzsh case-insensitive mid-word completionHow can I programmatically access zsh completion?Git package breaks bash-completion?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I'm trying to make a bash-completion function that will match infix like this:
candidates: Ay Axy Axx Bx
$ x<tab>
Should suggest Axx Axy Bx.
So far, I've come up with this:
f1 () {
local cur
cur=${2:-"."}
cand="Ay Axy Axx Bx"
COMPREPLY=( $(compgen -W "${cand}" | grep "$cur") )
return 0
}
complete -F f1 echo
Which seems to work in case 1:
$ echo x<tab>
Axx Axy Bx
But not in case 2:
$ echo y<tab> # -> readline substitutes with this:
$ echo A<tab><tab> # -> A expands to this:
Axx Axy Ay
The difference is that in case 1, there is no common prefix between the two candidates, so readline (I guess) leaves the x alone.
But in case 2, readline substitutes the y with an A, being the longest common prefix between the three matching candidates. Next completion now looks at the A and expands accordingly, thus defeating my purpose of expanding to any candidate with a y infix.
I've looked into the readline settings variables, to see if I can prevent it for replacing the y with A but had no luck.
Does anybody know how to prevent this, or another way to expand via infix? I'm aware that there are libraries like "fuzzy_bash_completion", but I'm trying to learn by doing here.
bash autocomplete
add a comment |
I'm trying to make a bash-completion function that will match infix like this:
candidates: Ay Axy Axx Bx
$ x<tab>
Should suggest Axx Axy Bx.
So far, I've come up with this:
f1 () {
local cur
cur=${2:-"."}
cand="Ay Axy Axx Bx"
COMPREPLY=( $(compgen -W "${cand}" | grep "$cur") )
return 0
}
complete -F f1 echo
Which seems to work in case 1:
$ echo x<tab>
Axx Axy Bx
But not in case 2:
$ echo y<tab> # -> readline substitutes with this:
$ echo A<tab><tab> # -> A expands to this:
Axx Axy Ay
The difference is that in case 1, there is no common prefix between the two candidates, so readline (I guess) leaves the x alone.
But in case 2, readline substitutes the y with an A, being the longest common prefix between the three matching candidates. Next completion now looks at the A and expands accordingly, thus defeating my purpose of expanding to any candidate with a y infix.
I've looked into the readline settings variables, to see if I can prevent it for replacing the y with A but had no luck.
Does anybody know how to prevent this, or another way to expand via infix? I'm aware that there are libraries like "fuzzy_bash_completion", but I'm trying to learn by doing here.
bash autocomplete
add a comment |
I'm trying to make a bash-completion function that will match infix like this:
candidates: Ay Axy Axx Bx
$ x<tab>
Should suggest Axx Axy Bx.
So far, I've come up with this:
f1 () {
local cur
cur=${2:-"."}
cand="Ay Axy Axx Bx"
COMPREPLY=( $(compgen -W "${cand}" | grep "$cur") )
return 0
}
complete -F f1 echo
Which seems to work in case 1:
$ echo x<tab>
Axx Axy Bx
But not in case 2:
$ echo y<tab> # -> readline substitutes with this:
$ echo A<tab><tab> # -> A expands to this:
Axx Axy Ay
The difference is that in case 1, there is no common prefix between the two candidates, so readline (I guess) leaves the x alone.
But in case 2, readline substitutes the y with an A, being the longest common prefix between the three matching candidates. Next completion now looks at the A and expands accordingly, thus defeating my purpose of expanding to any candidate with a y infix.
I've looked into the readline settings variables, to see if I can prevent it for replacing the y with A but had no luck.
Does anybody know how to prevent this, or another way to expand via infix? I'm aware that there are libraries like "fuzzy_bash_completion", but I'm trying to learn by doing here.
bash autocomplete
I'm trying to make a bash-completion function that will match infix like this:
candidates: Ay Axy Axx Bx
$ x<tab>
Should suggest Axx Axy Bx.
So far, I've come up with this:
f1 () {
local cur
cur=${2:-"."}
cand="Ay Axy Axx Bx"
COMPREPLY=( $(compgen -W "${cand}" | grep "$cur") )
return 0
}
complete -F f1 echo
Which seems to work in case 1:
$ echo x<tab>
Axx Axy Bx
But not in case 2:
$ echo y<tab> # -> readline substitutes with this:
$ echo A<tab><tab> # -> A expands to this:
Axx Axy Ay
The difference is that in case 1, there is no common prefix between the two candidates, so readline (I guess) leaves the x alone.
But in case 2, readline substitutes the y with an A, being the longest common prefix between the three matching candidates. Next completion now looks at the A and expands accordingly, thus defeating my purpose of expanding to any candidate with a y infix.
I've looked into the readline settings variables, to see if I can prevent it for replacing the y with A but had no luck.
Does anybody know how to prevent this, or another way to expand via infix? I'm aware that there are libraries like "fuzzy_bash_completion", but I'm trying to learn by doing here.
bash autocomplete
bash autocomplete
asked 2 days ago
NoMannNoMann
132 bronze badges
132 bronze badges
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f535762%2ftrying-for-infix-bash-completion%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f535762%2ftrying-for-infix-bash-completion%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown