You are not logged in.
Pages: 1
Is it possible to list diretories first (before files) in the zsh completion menu?
Offline
zstyle ':completion:*' list-dirs-first true
Online
zstyle ':completion:*' list-dirs-first true
I know this is a few months old, but this is actually exactly something I wanted to do, and this is exactly not working despite documentation saying it should. This is my .zshrc which is in my $HOME folder. Menu select and my aliases are loading properly so it is being sourced properly. I have tried both manually sourcing it and just opening a new shell to make sure it's being loaded. My .zshrc:
setopt appendhistory autocd beep nomatch
unsetopt extendedglob notify
bindkey -e
zstyle ':completion:*' menu select
zstyle ':completion:*' list-dirs-first true
zstyle :compinstall filename '/home/user/.zshrc'
autoload -Uz compinit
compinit
alias df="df -h"
alias ls="ls -h --group-directories-first"
But it doesn't work. Note ls is showing the ideal order, but pressing tab after vi does not:
% ls
alpha bravo charlie alpha1.txt alpha2.txt bravo1.txt bravo2.txt charlie.txt
% vi
aleph alpha/ alpha1.txt alpha2.txt bravo/ bravo1.txt bravo2.txt charlie/ charlie.txt
Last edited by dtjohnst (2017-07-30 22:25:57)
Offline
zstyle :compinstall filename '/home/usr/.zshrc'
is your username actually "usr"?
Online
zstyle :compinstall filename '/home/usr/.zshrc'
is your username actually "usr"?
Nope. I tried to sanitize it but I suck at spelling. Made it "user" in my original post. Sorry about that.
Last edited by dtjohnst (2017-07-30 22:26:20)
Offline
The point is: is this a badly redacted version and the actual file has effectively $HOME/.zshrc there or do you point a nonexisting file?
On top of that, I'm not 100% sure whether it matters, but the line is usually above the actual zstyle ':completion*'* settings.
Online
The point is: is this a badly redacted version and the actual file has effectively $HOME/.zshrc there or do you point a nonexisting file?
On top of that, I'm not 100% sure whether it matters, but the line is usually above the actual zstyle ':completion*'* settings.
The file is my $HOME/.zshrc as it appears on my system currently except for the username. I initially used the built-in new user wizard and removed the comments. I later added the list-dirs-first entry at the end of all the other options. When it didn't work, I removed all the extra settings to make sure there was no conflict with them except for menu-select to make sure it was working. The original is this (currently in $HOME/.zshrc.old) with my user's home directory changed from the actual path to $HOME:
zstyle ':completion:*' completer _expand _complete _ignored _correct _approximate _prefix
zstyle ':completion:*' expand prefix suffix
zstyle ':completion:*' ignore-parents parent pwd
zstyle ':completion:*' insert-unambiguous false
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
zstyle ':completion:*' list-suffixes true
zstyle ':completion:*' max-errors 2
zstyle ':completion:*' menu select=0
zstyle ':completion:*' preserve-prefix '//[^/]##/'
zstyle ':completion:*' prompt 'Found %e errors'
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
zstyle ':completion:*' squeeze-slashes true
#zstyle ':completion:*' file-patterns '*(-/):directories:directories %p:other-files'
zstyle ':completion:*' list-dirs-first true
zstyle :compinstall filename '$HOME/.zshrc'
autoload -Uz compinit
compinit
setopt appendhistory autocd beep extendedglob notify
unsetopt nomatch
bindkey -e
alias df="df -h"
alias ls="ls -h --group-directories-first"
Again, the only thing not appearing as it does on my system is the filename, which points to itself, but that is what the zsh new user wizard put. It seemed odd to me to put a line in a file pointing to itself, but I figured the wizard knew what it was doing. Should it point elsewhere? I did remove a couple of blank lines when I removed the automated comments too, but the wizard put the compinstall filename line after the rest. I did try moving it to the top and it made no difference though. I also tried something I had found elsewhere before list-dirs-first, and that is the zstyle that's been commented out with file-patterns. It seemed to do nothing in my setup from what I could tell. I believe the blank line I removed from the automated setup was between the last zstyle that points to the same file and the autoload. Some variables were doubled up in my .zshenv file, so I removed them from .zshrc and left them in .zshenv. It's basically the file generated by the new user install with 2 aliases added (I'm just toying with zsh at the moment so it's pretty bare). This is my .zshenv if it matters, again with my user folder changed to $HOME but the actual path is what's listed:
HISTFILE=$HOME/.histfile
HISTSIZE=1000
SAVEHIST=1000
PATH="/usr/local/sbin:/usr/local/bin:/usr/bin"
umask 027
Last edited by dtjohnst (2017-07-30 23:01:35)
Offline
I thought I'd eliminate all posibilities. I moved my /etc/zsh folder to /etc/zsh.old to get rid of anything in there. Then I created a test user called dtjohnst, used the zsh new user wizard with "default" or "recommended" settings for everything. It gave me this:
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
setopt appendhistory autocd beep extendedglob notify
unsetopt nomatch
bindkey -e
# End of lines configured by zsh-newuser-install
# The following lines were added by compinstall
zstyle :compinstall filename '/home/dtjohnst/.zshrc'
autoload -Uz compinit
compinit
# End of lines added by compinstall
I have tried this default file, and I have tried:
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
setopt appendhistory autocd beep extendedglob notify
unsetopt nomatch
bindkey -e
# End of lines configured by zsh-newuser-install
# The following lines were added by compinstall
zstyle :compinstall filename '/home/dtjohnst/.zshrc'
zstyle ':completion:*' list-dirs-first true
autoload -Uz compinit
compinit
# End of lines added by compinstall
And also:
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
setopt appendhistory autocd beep extendedglob notify
unsetopt nomatch
bindkey -e
# End of lines configured by zsh-newuser-install
# The following lines were added by compinstall
zstyle ':completion:*' list-dirs-first true
zstyle :compinstall filename '/home/dtjohnst/.zshrc'
autoload -Uz compinit
compinit
# End of lines added by compinstall
In all 3 cases, I get the same result. ls with group-directories-first gets it right, and vi then tab gets me purely alphabetical. Am I misunderstanding what list-directories-first is supposed to do?
% ls -h --group-directories-first
alpha bravo charlie aleph alpha1.txt alpha2.txt bravo1.txt bravo2.txt charlie.txt
% vi
aleph alpha/ alpha1.txt alpha2.txt bravo/ bravo1.txt bravo2.txt charlie/ charlie.txt
Offline
The self-reference is ok.
Do you have any zsh extensions installed (grml, omz)?
"zsh --version"?
Online
# Lines configured by zsh-newuser-install HISTFILE=~/.histfile HISTSIZE=1000 SAVEHIST=1000 setopt appendhistory autocd beep extendedglob notify unsetopt nomatch bindkey -e # End of lines configured by zsh-newuser-install # The following lines were added by compinstall zstyle :compinstall filename '/home/dtjohnst/.zshrc' autoload -Uz compinit compinit # End of lines added by compinstall
[...]
Hmm, you seem to have forgotten to redact your username again, here. Not sure why it matters if people know your username, though. I certainly don't mind if people know that my laptop username is *also* my forum/IRC/archweb/AUR/everything username.
It's hardly a security hole.
Last edited by eschwartz (2017-07-31 14:45:18)
Managing AUR repos The Right Way -- aurpublish (now a standalone tool)
Offline
dtjohnst wrote:# Lines configured by zsh-newuser-install HISTFILE=~/.histfile HISTSIZE=1000 SAVEHIST=1000 setopt appendhistory autocd beep extendedglob notify unsetopt nomatch bindkey -e # End of lines configured by zsh-newuser-install # The following lines were added by compinstall zstyle :compinstall filename '/home/dtjohnst/.zshrc' autoload -Uz compinit compinit # End of lines added by compinstall
[...]
Hmm, you seem to have forgotten to redact your username again, here. Not sure why it matters if people know your username, though. I certainly don't mind if people know that my laptop username is *also* my forum/IRC/archweb/AUR/everything username.
It's hardly a security hole.
Test account created using the same username as my forum account with no SSH login permission, so there was no reason to redact it. Knowing my username is half the puzzle of getting into my system from my perspective. It's not a huge deal if it gets out there I suppose, but it's easy enough to redact so why not?
Offline
Test account created using the same username as my forum account with no SSH login permission, so there was no reason to redact it. Knowing my username is half the puzzle of getting into my system from my perspective. It's not a huge deal if it gets out there I suppose, but it's easy enough to redact so why not?
Because sometimes other eyes actually do catch typos that turn out to be the source of the problem, which is why *exact* output is preferred.
And because if someone has a better chance of getting into your system once they know your username, this tells me you still allow password-based login, which is your real problem. Set up proper key-based auth and disallow password auth.
Managing AUR repos The Right Way -- aurpublish (now a standalone tool)
Offline
The self-reference is ok.
Do you have any zsh extensions installed (grml, omz)?
"zsh --version"?
No extensions installed.
zsh 5.3.1 (x86_64-unknown-linux-gnu)
Offline
dtjohnst wrote:Test account created using the same username as my forum account with no SSH login permission, so there was no reason to redact it. Knowing my username is half the puzzle of getting into my system from my perspective. It's not a huge deal if it gets out there I suppose, but it's easy enough to redact so why not?
Because sometimes other eyes actually do catch typos that turn out to be the source of the problem, which is why *exact* output is preferred.
And because if someone has a better chance of getting into your system once they know your username, this tells me you still allow password-based login, which is your real problem. Set up proper key-based auth and disallow password auth.
My SSH is key-based. But some of the other people here at work know my forum usernames and have physical access to my machine here at work. I'll take your advice and attempt to remember to always use this test account to provide information as-is-written.
Offline
Ah, sh** - it's not the default:
zstyle ':completion:*:matches' group 'yes'
zstyle ':completion:*' group-name ''
About your security concerns: physical access generally means game-over. I reboot into runlevel 1 and do whatever I want.
I can read your username easily, change your password - or replace your login to also store the plaintext password or send me a mail (or fetch the hash and attack it back home)
Online
My SSH is key-based. But some of the other people here at work know my forum usernames and have physical access to my machine here at work. I'll take your advice and attempt to remember to always use this test account to provide information as-is-written.
I'd just like to add my +1 to seth's statement.
If you disabled password-based SSH login, and you're only worried about people with physical access, they will either never get in even with knowing your username, or they will do the smart thing and circumvent silly things like logins altogether. Either way, this whole "security through (badly-implemented) obscurity" thing is not worth bothering with.
Managing AUR repos The Right Way -- aurpublish (now a standalone tool)
Offline
Ah, sh** - it's not the default:
zstyle ':completion:*:matches' group 'yes' zstyle ':completion:*' group-name ''
About your security concerns: physical access generally means game-over. I reboot into runlevel 1 and do whatever I want.
I can read your username easily, change your password - or replace your login to also store the plaintext password or send me a mail (or fetch the hash and attack it back home)
Working fine now, thanks. Appreciate your help.
Offline
Pages: 1