Syntax highlighting in terminal

I'm using Gnome Terminal. All my input have the same color.

But today I was using Powershell in Windows and it has different colors for a command, for flags and for options.

How I can do the same in Ubuntu? I have tried themes, but they only change the background but not my input.

(I took image from internet, so pay attention only to upper selection) enter image description here

UPD. I want to have colors when I write command. For example when I write git commit -m "Hello" - git should be yellow, commit white, -m grey and "Hello" green.


Solution 1:

Bash (the default shell of Ubuntu) doesn't have this ability. It uses GNU readline, and likely would be a serious effort to implement it.

But, there are mechanisms to use different shells. Two common ones that are talked about a lot are:

  • oh-my-zsh - "Your terminal never felt this good before.
  • fish - "A command line shell for the 90s"

See the respective sites for up to date setup instructions. But in general the shells are not that hard to configure. Fish, for instance is:

sudo apt install fish
chsh -s /usr/bin/fish
# logout/login

Then, if you want to switch back

chsh -s /bin/bash
# logout/login

oh-my-zsh isn't as easy, but it's the same idea.