Sometimes on the server, if the disk IO load is heavy, the terminal is stuck by the tab completion. Ctrl-C|D|Z all don't quit.Each time I have to login from another session, find the stuck pty and kill it.Is there any way to prevent the tab completion hang?
How to avoid the hang of tab completion in home folder?
linux;bash;autocomplete
First idea - disable file name completions, while the disk is high loaded. It is affect only filenames, other completions stay working. Because, I think they doesn't cause hang.Create file .bash_completion in the home directory and put this code to there.#!/bin/bash### We are needed redefine original _filedir function### and add new functionality to it## for this, output the original function code and add the word 'original'# in the beginning of it - now we are have _filedir renamed to# 'original_filedir'eval original$(declare -f _filedir)# Define our own _filedir function, which will check disk load# and: # if load are low - call original function.# if load are high - stop further execution. _filedir() {    io_load_limit=10    io_load=$(awk '/sda /{print $12}' /proc/diskstats)    if ((io_load > io_load_limit)); then        echo -n completion disabled - a lot i/o        return    fi      original_filedir}Also, the same trick can be done with _completion-loader function. It sets up dynamic completion loading. In the Ubuntu, the main completion code resides in the /usr/share/bash-completion/bash_completion file and others, customized for specific program, reside in the /usr/share/bash-completion/completions/ directory.When bash starts, it reads /usr/share/bash-completion/bash_completion file, and then, if you are typing apt-get, for example, _completion-loader runs and loads apt-get completion rules from the /usr/share/bash-completion/completions/apt-get. It is also affect to I/O and can be cause of hanging.I decided use /proc/diskstats for evaluating disk activity. You can use another way. Limit value was chosen randomly.Second idea - setup limit for i/o usage, like this.