(This is sort of an off-topic question, I hope that's okay.)
I love the ALTERNATIVE_COMPLETION_TYPE option.
Is this special to bashrun, or is there a simple way to get similar behavior in regular Bash - i.e. switching from cycling options (menu-complete) to listing them (complete) if there are more than n options?
(I'd need this for some remote servers.)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is a bashrun-specific feature. Note that the type of completion is switched if the number of lines of the terminal exceeds the COMPLETION_THRESHOLD, so switching to ALTERNATIVE_COMPLETION_TYPE is rather side-effect of changing the terminal size. Afaik there's no way of switching completion types "on the fly", based on how many options a current completion attempt yields (this is what your question seems to imply).
For bash, how about using something like this:
bind '"\t": menu-complete'
bind '"\ew": complete'
So that tab uses menu-complete, and Alt+w (or whatever you like) uses complete.
If you want to switch the type that the tab key uses, you'll have to use something like this:
COMPLETION_TYPE=complete
switch_type () {
if [[ "$COMPLETION_TYPE" == "complete" ]]; then
bind '"\t": menu-complete'
COMPLETION_TYPE="menu-complete"
else
bind '"\t": complete'
COMPLETION_TYPE="complete"
fi
}
bind -x '"\ew": switch_type'
So you can actively switch completion types by hitting Alt+w.
Hope this helps,
Henning
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
(This is sort of an off-topic question, I hope that's okay.)
I love the ALTERNATIVE_COMPLETION_TYPE option.
Is this special to bashrun, or is there a simple way to get similar behavior in regular Bash - i.e. switching from cycling options (menu-complete) to listing them (complete) if there are more than n options?
(I'd need this for some remote servers.)
This is a bashrun-specific feature. Note that the type of completion is switched if the number of lines of the terminal exceeds the COMPLETION_THRESHOLD, so switching to ALTERNATIVE_COMPLETION_TYPE is rather side-effect of changing the terminal size. Afaik there's no way of switching completion types "on the fly", based on how many options a current completion attempt yields (this is what your question seems to imply).
For bash, how about using something like this:
bind '"\t": menu-complete'
bind '"\ew": complete'
So that tab uses menu-complete, and Alt+w (or whatever you like) uses complete.
If you want to switch the type that the tab key uses, you'll have to use something like this:
COMPLETION_TYPE=complete
switch_type () {
if [[ "$COMPLETION_TYPE" == "complete" ]]; then
bind '"\t": menu-complete'
COMPLETION_TYPE="menu-complete"
else
bind '"\t": complete'
COMPLETION_TYPE="complete"
fi
}
bind -x '"\ew": switch_type'
So you can actively switch completion types by hitting Alt+w.
Hope this helps,
Henning
Thanks a lot for the quick and informative response!
I'll give that script a try, see whether it fits my workflow.
Thanks again!