Zsh tab completions not working as desired for partial paths The 2019 Stack Overflow Developer Survey Results Are InZSH: insert completion on first tab even if ambiguous?How to make ZSH tab completion work with two tabsManual tab completions in zshzsh completion - show more options than just the aliasHow can I keep the trailing slash after choosing a directory from the zsh completion options?Combining zsh’s tab completion with case insensitivityBash tab completion for aliaseszsh: Tab completion for function with Git commandsCompletion for the first argument of cd OLD NEWTreat command like another for completion purposes
Are there any other methods to apply to solving simultaneous equations?
What are the motivations for publishing new editions of an existing textbook, beyond new discoveries in a field?
How to answer pointed "are you quitting" questioning when I don't want them to suspect
Identify boardgame from Big movie
How to deal with fear of taking dependencies
Is "plugging out" electronic devices an American expression?
Loose spokes after only a few rides
I see my dog run
How to save as into a customized destination on macOS?
Is there a symbol for a right arrow with a square in the middle?
Where to refill my bottle in India?
Why hard-Brexiteers don't insist on a hard border to prevent illegal immigration after Brexit?
What is the meaning of Triage in Cybersec world?
Protecting Dualbooting Windows from dangerous code (like rm -rf)
Did Scotland spend $250,000 for the slogan "Welcome to Scotland"?
Write faster on AT24C32
Origin of "cooter" meaning "vagina"
Shouldn't "much" here be used instead of "more"?
Can a rogue use sneak attack with weapons that have the thrown property even if they are not thrown?
Do these rules for Critical Successes and Critical Failures seem Fair?
Which Sci-Fi work first showed weapon of galactic-scale mass destruction?
Did 3000BC Egyptians use meteoric iron weapons?
Building a conditional check constraint
What does "fetching by region is not available for SAM files" means?
Zsh tab completions not working as desired for partial paths
The 2019 Stack Overflow Developer Survey Results Are InZSH: insert completion on first tab even if ambiguous?How to make ZSH tab completion work with two tabsManual tab completions in zshzsh completion - show more options than just the aliasHow can I keep the trailing slash after choosing a directory from the zsh completion options?Combining zsh’s tab completion with case insensitivityBash tab completion for aliaseszsh: Tab completion for function with Git commandsCompletion for the first argument of cd OLD NEWTreat command like another for completion purposes
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I want case-insensitive fuzzy completion for files and directories in zsh. After reading the manual for a few hours, this is what I came up with:
zstyle ':completion:*:*:*:*:globbed-files' matcher 'r:|?=** m:a-z-=A-Z_'
zstyle ':completion:*:*:*:*:local-directories' matcher 'r:|?=** m:a-z-=A-Z_'
zstyle ':completion:*:*:*:*:directories' matcher 'r:|?=** m:a-z-=A-Z_'
Additionally, I want pressing TAB once to display possible completions, only modifying what I have typed if there is exactly one completion. Then pressing TAB a second time should put me into "menu completion" mode. Based on the manuals, I came up with this:
zstyle ':completion:*' menu select
Now everything works as it should except in one circumstance. I have two folders Desktop and .rstudio-desktop in my home directory. Since I have setopt globdots, I expect typing the following:
$ cd ~/dktop<TAB>
to leave my command as entered, and display as completion candidates Desktop and .rstudio-desktop. Instead, it removes dktop, leaving me with the following:
$ cd ~/
I have looked at all of the relevant manuals, guides, Stack Exchange questions, and various other sources. But whatever I do, I can't make this work.
Interestingly, though, if I'm in the home directory and type the following then everything works as expected:
$ cd dktop<TAB>
That is, it's only a problem with non-leading segments of paths (and you can see with C-x h that this corresponds to the directories tag rather than the local-directories tag being used).
For easy reproducibility, here is a ~/.zshrc that will reproduce the situation and behavior described above (tested on a fresh El Capitan virtual machine with zsh from Homebrew).
zsh autocomplete
add a comment |
I want case-insensitive fuzzy completion for files and directories in zsh. After reading the manual for a few hours, this is what I came up with:
zstyle ':completion:*:*:*:*:globbed-files' matcher 'r:|?=** m:a-z-=A-Z_'
zstyle ':completion:*:*:*:*:local-directories' matcher 'r:|?=** m:a-z-=A-Z_'
zstyle ':completion:*:*:*:*:directories' matcher 'r:|?=** m:a-z-=A-Z_'
Additionally, I want pressing TAB once to display possible completions, only modifying what I have typed if there is exactly one completion. Then pressing TAB a second time should put me into "menu completion" mode. Based on the manuals, I came up with this:
zstyle ':completion:*' menu select
Now everything works as it should except in one circumstance. I have two folders Desktop and .rstudio-desktop in my home directory. Since I have setopt globdots, I expect typing the following:
$ cd ~/dktop<TAB>
to leave my command as entered, and display as completion candidates Desktop and .rstudio-desktop. Instead, it removes dktop, leaving me with the following:
$ cd ~/
I have looked at all of the relevant manuals, guides, Stack Exchange questions, and various other sources. But whatever I do, I can't make this work.
Interestingly, though, if I'm in the home directory and type the following then everything works as expected:
$ cd dktop<TAB>
That is, it's only a problem with non-leading segments of paths (and you can see with C-x h that this corresponds to the directories tag rather than the local-directories tag being used).
For easy reproducibility, here is a ~/.zshrc that will reproduce the situation and behavior described above (tested on a fresh El Capitan virtual machine with zsh from Homebrew).
zsh autocomplete
Can't reproduce.zsh 5.3.1onArch Linux.cd ~/dktop<tab>yieldscd ~/Desktop.
– PythonNut
Feb 8 '17 at 21:34
@PythonNut Withzsh 5.3.1on OS X the issue does reproduce. It's interesting that there is a difference between the operating systems.
– Radon Rosborough
Feb 12 '17 at 21:22
1
@PythonNut Actually, I bet this is because Linux is case-sensitive and macOS is case-insensitive.
– Radon Rosborough
Feb 13 '17 at 22:33
Just as a friendly reminder not all Macs / macOS are case-insensitive it depends on wether your disk is formated case-insensitive or not.
– konqui
May 11 '18 at 15:05
add a comment |
I want case-insensitive fuzzy completion for files and directories in zsh. After reading the manual for a few hours, this is what I came up with:
zstyle ':completion:*:*:*:*:globbed-files' matcher 'r:|?=** m:a-z-=A-Z_'
zstyle ':completion:*:*:*:*:local-directories' matcher 'r:|?=** m:a-z-=A-Z_'
zstyle ':completion:*:*:*:*:directories' matcher 'r:|?=** m:a-z-=A-Z_'
Additionally, I want pressing TAB once to display possible completions, only modifying what I have typed if there is exactly one completion. Then pressing TAB a second time should put me into "menu completion" mode. Based on the manuals, I came up with this:
zstyle ':completion:*' menu select
Now everything works as it should except in one circumstance. I have two folders Desktop and .rstudio-desktop in my home directory. Since I have setopt globdots, I expect typing the following:
$ cd ~/dktop<TAB>
to leave my command as entered, and display as completion candidates Desktop and .rstudio-desktop. Instead, it removes dktop, leaving me with the following:
$ cd ~/
I have looked at all of the relevant manuals, guides, Stack Exchange questions, and various other sources. But whatever I do, I can't make this work.
Interestingly, though, if I'm in the home directory and type the following then everything works as expected:
$ cd dktop<TAB>
That is, it's only a problem with non-leading segments of paths (and you can see with C-x h that this corresponds to the directories tag rather than the local-directories tag being used).
For easy reproducibility, here is a ~/.zshrc that will reproduce the situation and behavior described above (tested on a fresh El Capitan virtual machine with zsh from Homebrew).
zsh autocomplete
I want case-insensitive fuzzy completion for files and directories in zsh. After reading the manual for a few hours, this is what I came up with:
zstyle ':completion:*:*:*:*:globbed-files' matcher 'r:|?=** m:a-z-=A-Z_'
zstyle ':completion:*:*:*:*:local-directories' matcher 'r:|?=** m:a-z-=A-Z_'
zstyle ':completion:*:*:*:*:directories' matcher 'r:|?=** m:a-z-=A-Z_'
Additionally, I want pressing TAB once to display possible completions, only modifying what I have typed if there is exactly one completion. Then pressing TAB a second time should put me into "menu completion" mode. Based on the manuals, I came up with this:
zstyle ':completion:*' menu select
Now everything works as it should except in one circumstance. I have two folders Desktop and .rstudio-desktop in my home directory. Since I have setopt globdots, I expect typing the following:
$ cd ~/dktop<TAB>
to leave my command as entered, and display as completion candidates Desktop and .rstudio-desktop. Instead, it removes dktop, leaving me with the following:
$ cd ~/
I have looked at all of the relevant manuals, guides, Stack Exchange questions, and various other sources. But whatever I do, I can't make this work.
Interestingly, though, if I'm in the home directory and type the following then everything works as expected:
$ cd dktop<TAB>
That is, it's only a problem with non-leading segments of paths (and you can see with C-x h that this corresponds to the directories tag rather than the local-directories tag being used).
For easy reproducibility, here is a ~/.zshrc that will reproduce the situation and behavior described above (tested on a fresh El Capitan virtual machine with zsh from Homebrew).
zsh autocomplete
zsh autocomplete
edited Dec 15 '16 at 2:20
Radon Rosborough
asked Dec 15 '16 at 2:14
Radon RosboroughRadon Rosborough
254212
254212
Can't reproduce.zsh 5.3.1onArch Linux.cd ~/dktop<tab>yieldscd ~/Desktop.
– PythonNut
Feb 8 '17 at 21:34
@PythonNut Withzsh 5.3.1on OS X the issue does reproduce. It's interesting that there is a difference between the operating systems.
– Radon Rosborough
Feb 12 '17 at 21:22
1
@PythonNut Actually, I bet this is because Linux is case-sensitive and macOS is case-insensitive.
– Radon Rosborough
Feb 13 '17 at 22:33
Just as a friendly reminder not all Macs / macOS are case-insensitive it depends on wether your disk is formated case-insensitive or not.
– konqui
May 11 '18 at 15:05
add a comment |
Can't reproduce.zsh 5.3.1onArch Linux.cd ~/dktop<tab>yieldscd ~/Desktop.
– PythonNut
Feb 8 '17 at 21:34
@PythonNut Withzsh 5.3.1on OS X the issue does reproduce. It's interesting that there is a difference between the operating systems.
– Radon Rosborough
Feb 12 '17 at 21:22
1
@PythonNut Actually, I bet this is because Linux is case-sensitive and macOS is case-insensitive.
– Radon Rosborough
Feb 13 '17 at 22:33
Just as a friendly reminder not all Macs / macOS are case-insensitive it depends on wether your disk is formated case-insensitive or not.
– konqui
May 11 '18 at 15:05
Can't reproduce.
zsh 5.3.1 on Arch Linux. cd ~/dktop<tab> yields cd ~/Desktop.– PythonNut
Feb 8 '17 at 21:34
Can't reproduce.
zsh 5.3.1 on Arch Linux. cd ~/dktop<tab> yields cd ~/Desktop.– PythonNut
Feb 8 '17 at 21:34
@PythonNut With
zsh 5.3.1 on OS X the issue does reproduce. It's interesting that there is a difference between the operating systems.– Radon Rosborough
Feb 12 '17 at 21:22
@PythonNut With
zsh 5.3.1 on OS X the issue does reproduce. It's interesting that there is a difference between the operating systems.– Radon Rosborough
Feb 12 '17 at 21:22
1
1
@PythonNut Actually, I bet this is because Linux is case-sensitive and macOS is case-insensitive.
– Radon Rosborough
Feb 13 '17 at 22:33
@PythonNut Actually, I bet this is because Linux is case-sensitive and macOS is case-insensitive.
– Radon Rosborough
Feb 13 '17 at 22:33
Just as a friendly reminder not all Macs / macOS are case-insensitive it depends on wether your disk is formated case-insensitive or not.
– konqui
May 11 '18 at 15:05
Just as a friendly reminder not all Macs / macOS are case-insensitive it depends on wether your disk is formated case-insensitive or not.
– konqui
May 11 '18 at 15:05
add a comment |
1 Answer
1
active
oldest
votes
One possible solution is to do:
bindkey "^I" expand-word
This will cause tab to expand ~/ to the absolute path.
Maybe I'm missing something, but I don't see how this relates in any way to fuzzy tab completions, or to solving the problem outlined above. If I do as you suggest, then pressing TAB will give mecd /Users/raxod502/dktop, and completion is disabled.
– Radon Rosborough
May 1 '18 at 23:01
@RadonRosborough The hope was that by expanding~/to its absolute path that fuzzy completion would start working. It seemed like one of those cases where the problem is that it evaluates it once but you actually need it to evaluate twice to work, so having the absolute path instead of~/would mean it'd go back to only needing one evaluation. But crap, I'm sorry, I forgot that bindkey replaces old bindings, and I can't find anything that says if it's even possible to bindkey two functions to one key. Without my bindkey, does your completion work as intended when given absolute paths?
– ConstipatedNinja
May 2 '18 at 15:48
No. It makes no difference whether the input path is~/dktopor/Users/raxod502/dktop; the result is the same, namely thatdktopis deleted when I press TAB.
– Radon Rosborough
May 2 '18 at 21:30
add a comment |
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%2f330481%2fzsh-tab-completions-not-working-as-desired-for-partial-paths%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
One possible solution is to do:
bindkey "^I" expand-word
This will cause tab to expand ~/ to the absolute path.
Maybe I'm missing something, but I don't see how this relates in any way to fuzzy tab completions, or to solving the problem outlined above. If I do as you suggest, then pressing TAB will give mecd /Users/raxod502/dktop, and completion is disabled.
– Radon Rosborough
May 1 '18 at 23:01
@RadonRosborough The hope was that by expanding~/to its absolute path that fuzzy completion would start working. It seemed like one of those cases where the problem is that it evaluates it once but you actually need it to evaluate twice to work, so having the absolute path instead of~/would mean it'd go back to only needing one evaluation. But crap, I'm sorry, I forgot that bindkey replaces old bindings, and I can't find anything that says if it's even possible to bindkey two functions to one key. Without my bindkey, does your completion work as intended when given absolute paths?
– ConstipatedNinja
May 2 '18 at 15:48
No. It makes no difference whether the input path is~/dktopor/Users/raxod502/dktop; the result is the same, namely thatdktopis deleted when I press TAB.
– Radon Rosborough
May 2 '18 at 21:30
add a comment |
One possible solution is to do:
bindkey "^I" expand-word
This will cause tab to expand ~/ to the absolute path.
Maybe I'm missing something, but I don't see how this relates in any way to fuzzy tab completions, or to solving the problem outlined above. If I do as you suggest, then pressing TAB will give mecd /Users/raxod502/dktop, and completion is disabled.
– Radon Rosborough
May 1 '18 at 23:01
@RadonRosborough The hope was that by expanding~/to its absolute path that fuzzy completion would start working. It seemed like one of those cases where the problem is that it evaluates it once but you actually need it to evaluate twice to work, so having the absolute path instead of~/would mean it'd go back to only needing one evaluation. But crap, I'm sorry, I forgot that bindkey replaces old bindings, and I can't find anything that says if it's even possible to bindkey two functions to one key. Without my bindkey, does your completion work as intended when given absolute paths?
– ConstipatedNinja
May 2 '18 at 15:48
No. It makes no difference whether the input path is~/dktopor/Users/raxod502/dktop; the result is the same, namely thatdktopis deleted when I press TAB.
– Radon Rosborough
May 2 '18 at 21:30
add a comment |
One possible solution is to do:
bindkey "^I" expand-word
This will cause tab to expand ~/ to the absolute path.
One possible solution is to do:
bindkey "^I" expand-word
This will cause tab to expand ~/ to the absolute path.
answered May 1 '18 at 18:07
ConstipatedNinjaConstipatedNinja
56614
56614
Maybe I'm missing something, but I don't see how this relates in any way to fuzzy tab completions, or to solving the problem outlined above. If I do as you suggest, then pressing TAB will give mecd /Users/raxod502/dktop, and completion is disabled.
– Radon Rosborough
May 1 '18 at 23:01
@RadonRosborough The hope was that by expanding~/to its absolute path that fuzzy completion would start working. It seemed like one of those cases where the problem is that it evaluates it once but you actually need it to evaluate twice to work, so having the absolute path instead of~/would mean it'd go back to only needing one evaluation. But crap, I'm sorry, I forgot that bindkey replaces old bindings, and I can't find anything that says if it's even possible to bindkey two functions to one key. Without my bindkey, does your completion work as intended when given absolute paths?
– ConstipatedNinja
May 2 '18 at 15:48
No. It makes no difference whether the input path is~/dktopor/Users/raxod502/dktop; the result is the same, namely thatdktopis deleted when I press TAB.
– Radon Rosborough
May 2 '18 at 21:30
add a comment |
Maybe I'm missing something, but I don't see how this relates in any way to fuzzy tab completions, or to solving the problem outlined above. If I do as you suggest, then pressing TAB will give mecd /Users/raxod502/dktop, and completion is disabled.
– Radon Rosborough
May 1 '18 at 23:01
@RadonRosborough The hope was that by expanding~/to its absolute path that fuzzy completion would start working. It seemed like one of those cases where the problem is that it evaluates it once but you actually need it to evaluate twice to work, so having the absolute path instead of~/would mean it'd go back to only needing one evaluation. But crap, I'm sorry, I forgot that bindkey replaces old bindings, and I can't find anything that says if it's even possible to bindkey two functions to one key. Without my bindkey, does your completion work as intended when given absolute paths?
– ConstipatedNinja
May 2 '18 at 15:48
No. It makes no difference whether the input path is~/dktopor/Users/raxod502/dktop; the result is the same, namely thatdktopis deleted when I press TAB.
– Radon Rosborough
May 2 '18 at 21:30
Maybe I'm missing something, but I don't see how this relates in any way to fuzzy tab completions, or to solving the problem outlined above. If I do as you suggest, then pressing TAB will give me
cd /Users/raxod502/dktop, and completion is disabled.– Radon Rosborough
May 1 '18 at 23:01
Maybe I'm missing something, but I don't see how this relates in any way to fuzzy tab completions, or to solving the problem outlined above. If I do as you suggest, then pressing TAB will give me
cd /Users/raxod502/dktop, and completion is disabled.– Radon Rosborough
May 1 '18 at 23:01
@RadonRosborough The hope was that by expanding
~/ to its absolute path that fuzzy completion would start working. It seemed like one of those cases where the problem is that it evaluates it once but you actually need it to evaluate twice to work, so having the absolute path instead of ~/ would mean it'd go back to only needing one evaluation. But crap, I'm sorry, I forgot that bindkey replaces old bindings, and I can't find anything that says if it's even possible to bindkey two functions to one key. Without my bindkey, does your completion work as intended when given absolute paths?– ConstipatedNinja
May 2 '18 at 15:48
@RadonRosborough The hope was that by expanding
~/ to its absolute path that fuzzy completion would start working. It seemed like one of those cases where the problem is that it evaluates it once but you actually need it to evaluate twice to work, so having the absolute path instead of ~/ would mean it'd go back to only needing one evaluation. But crap, I'm sorry, I forgot that bindkey replaces old bindings, and I can't find anything that says if it's even possible to bindkey two functions to one key. Without my bindkey, does your completion work as intended when given absolute paths?– ConstipatedNinja
May 2 '18 at 15:48
No. It makes no difference whether the input path is
~/dktop or /Users/raxod502/dktop; the result is the same, namely that dktop is deleted when I press TAB.– Radon Rosborough
May 2 '18 at 21:30
No. It makes no difference whether the input path is
~/dktop or /Users/raxod502/dktop; the result is the same, namely that dktop is deleted when I press TAB.– Radon Rosborough
May 2 '18 at 21:30
add a comment |
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%2f330481%2fzsh-tab-completions-not-working-as-desired-for-partial-paths%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
Can't reproduce.
zsh 5.3.1onArch Linux.cd ~/dktop<tab>yieldscd ~/Desktop.– PythonNut
Feb 8 '17 at 21:34
@PythonNut With
zsh 5.3.1on OS X the issue does reproduce. It's interesting that there is a difference between the operating systems.– Radon Rosborough
Feb 12 '17 at 21:22
1
@PythonNut Actually, I bet this is because Linux is case-sensitive and macOS is case-insensitive.
– Radon Rosborough
Feb 13 '17 at 22:33
Just as a friendly reminder not all Macs / macOS are case-insensitive it depends on wether your disk is formated case-insensitive or not.
– konqui
May 11 '18 at 15:05