Shell tips

It is easy to add autocompletion to commands in ksh, however they are limited because they have to be evaluated when the shell is starting.

In the following example, we can parse the file

~/.ssh/known_hosts
to get hostnames and use this list to set autocompletion entries for some commands:
HOSTS_LIST=$(awk '{split($1,a,","); print a[1]}' ~/.ssh/known_hosts)
set -A complete_ssh -- $HOSTS_LIST
set -A complete_ping -- $HOSTS_LIST
set -A complete_sndioctl_1 -- $(sndioctl | cut -d= -f 1)

In this other example, we autocomplete differently depending on the parameter position

set -A complete_rclone_1 -- ncdu ls copy sync
set -A complete_rclone_2 -- $(rclone listremotes)
Adding autocompletion entries is easy but in ksh it is evaluated at runtime, so you should avoid time consuming evaluations, and some commands like scp or git can't receive much useful completion.

More information can be found about this feature .