Command line auto complete tab key not work in terminal for VNC Viewer

Linux Aug 21, 2020 Viewed 756 Comments 0

I installed vncserver on the Ubuntu server. After connecting through VNC Viewer, open the terminal to input commands and press the Tab key of the keyboard, but no effect of auto-completion. It was solved following these steps.

1. Add bash_completion in .bashrc

Make sure that my .bashrc file contains something like.

if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi

so that a file containing bash completion info is actually sourced. In my case, /etc/bash_completion pointed to /usr/share/bash-completion/bash_completion which contained the stuff to set up. For reference, the end of my .bashrc looked like this:

if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi

2. Disable the behaviour of tab changing windows

This is done in the file ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml by changing the line

<property name="Tab" type="string" value="switch_window_key"/>

to

<property name="Tab" type="empty"/>

3. Reboot or restart your VNC server

Updated Aug 21, 2020