简体   繁体   中英

Showing only basename of path in bash autocompletion

I notice that the autocompletion for the command 'cd' will only show the basename of a path, for example:

cd ../d/s[tab] scripts secure

But when I build my own autocomplete function by editing COMPREPLY, it will always show the whole path as the results, like this:

my_func ../d/s[tab] ../d/scripts ../d/secure

Is there a way to make my autocomplete work as 'cd'?

如果只需要显示路径的基本名称,则需要在COMPREPLY中使用ls -1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM