help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] change completion from ls to ls -l


From: Geir Hauge
Subject: Re: [Help-bash] change completion from ls to ls -l
Date: Mon, 7 Apr 2014 14:44:04 +0200

2014-04-07 7:56 GMT+02:00 Jonathan Reed <address@hidden>:
>
> Is there an easy way to edit this functionality? I'd prefer to use *ls -l *
> instead*.* I tried aliasing *ls* to *ls -l* to no avail.
>

Inside a completion function, you can detect whether <TAB><TAB> was used
via the COMP_TYPE variable, so you could hack up a default completion
function that populates COMPREPLY with ls -ld output in such a case.
Something like:

_default_completion() {
    if (( COMP_TYPE == 63 )); then
        mapfile -t COMPREPLY < <(command ls -ld -- "$2"* 2>/dev/null)
    fi
}
complete -F _default_completion -o default -o bashdefault -D

This probably has several edge cases I've yet to think of, but I'm
pretty sure it will break bash-completion if you use that. I don't want
to dive into that mess though. Left as an exercise etc...

-- 
Geir Hauge


reply via email to

[Prev in Thread] Current Thread [Next in Thread]