9

I use Ubuntu on a daily basis, recently I've seen that the terminal on Kali Linux behaves differently from the terminal on Ubuntu... I can see the end of the command that I'm typing based on the history of commands that I've typed like the following:

Picture of terminal showing the visual autocompletion feature

I know I can use autocompletion by pressing tab, but this feature is something else since I can see the command before pressing tab... That's not a Kali related question too since I just want to replicate this feature on Ubuntu 20.04. Is it a feature that I can easily install on Ubuntu by installing some tool with apt install? Or is it a configuration that I need to do?

muru
  • 197,895
  • 55
  • 485
  • 740
raylight
  • 493

3 Answers3

19

Kali uses zsh instead of bash as the default shell and the feature you are referring to is called autosuggestions.

Before you begin, you will need to set up zsh if you haven't already.

Run the following to install zsh and follow the instructions when prompted (it's best to accept the defaults and auto-generate your zshrc file):

sudo add-apt-repository universe
sudo apt update
sudo apt install zsh zsh-syntax-highlighting
zsh

For 20.04 or newer, run the following command to install the zsh-autosuggestions package:

sudo apt update
sudo apt install zsh-autosuggestions

For Ubuntu 18.04, you can run the following commands to install the zsh-autosuggestions repository Keep in mind that the owner of the key may distribute updates, packages and repositories that your system will trust (more information):

echo 'deb http://download.opensuse.org/repositories/shells:/zsh-users:/zsh-autosuggestions/xUbuntu_18.04/ /' | sudo tee /etc/apt/sources.list.d/shells:zsh-users:zsh-autosuggestions.list
curl -fsSL https://download.opensuse.org/repositories/shells:zsh-users:zsh-autosuggestions/xUbuntu_18.04/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/shells_zsh-users_zsh-autosuggestions.gpg > /dev/null
sudo apt update
sudo apt install zsh-autosuggestions

Finally, run the following commands to add autosuggestions to your zshrc file:

cp ~/.zshrc ~/.zshrcbackup
echo "source $(dpkg -L zsh-autosuggestions | grep 'zsh$')" | tee -a ~/.zshrc
echo "source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" | tee -a ~/.zshrc

and don't forget to source your ~/.zshrc file to apply the changes (if you are in bash or another shell, run the zsh command first):

source ~/.zshrc

See here if you want to make zsh the default shell.

Run the following command to search for other plugins, plugin managers, related packages (like fuzzyfinder), and other compatible shells:

apt-cache search zsh
mchid
  • 43,546
  • 8
  • 97
  • 150
0

If you like the Kali terminal layout so much like me what I did was to just backup the existing .zshrc file,

cp ~/.zshrc ~/.zshrc.bak

and I just copied the .zshrc file from my kali backup and ran,

source ~/.zshrc

And it pretty much worked exactly like in kali

I just put the content of the file here using pastebinit,

https://paste.ubuntu.com/p/GqtRtdDpQy/

0

When using zsh you can apply syntax highlighting:

(This way you can also check if your command is correct or not/helps as a sort of autocomplete).

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git

echo "source ${(q-)PWD}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc

Apply to shell:

source ./zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
ajmeese7
  • 117
Collega
  • 101