I'm trying to get a auto completion for folders that I don't have permission to view / enter, my first thought was to use compgen and sudo to do the completion manually, but looks like compgen is a shell builtin, so launching it with sudo may not work.
Also, if I wrote customized completion function for folders, how can I overwrite for every command? I don't want to do complete command for everything.
Or is there any alternative ways?
EDIT
This is useful in a environment where you grant user sudo permission (to run arbitrary commands), but don't want them to login / su as root, so when they need to navigate to some folders accessible only by root, they can quickly view the contents without run commands like sudo ls XX
su root? :O/root? It won't work because you don't have permission to read the contents of it. That's what I want byinaccessible folders