Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Ubuntu terminal to look like Git-bash of Window

Is there a way to change/replace the default Ubuntu terminal with Git-bash(look and behavior) of Window? Basically, the terminal should display all the necessary information related with current branch/repo, just like it does in Window.

I am using VS Code and had configured Git-Bash with it for Window platform. But couldn't find anything which would let me achieve the same on Ubuntu platform.

I have checked following links for answers -

  1. Git bash on Ubuntu. -> After changes, it shows current branch but all entire text/string becomes monotonous white.
  2. How can I have a shell for git like in Windows?. -> Only branch name's text-color remains as green and everything else becomes white.
like image 286
Sujit Kumar Singh Avatar asked Apr 17 '19 14:04

Sujit Kumar Singh


1 Answers

After @kostix suggestion, I searched the internet with proper key-words and found this question thread and then finally to this page. After trying approaches mentioned there, I ended up with the following code which works much better. Add these code in the .bashrc file present in Home folder. Find it using ~/.bashrc/ command.

# git branch info if present
parse_git_branch() {
     git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\[\033[36m\]\u@\h\[\033[00m\] \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] \n\[\033[1;31m\]>>\[\033[00m\] "

Ubuntu's terminal screenshot -

enter image description here

VS code's terminal screenshot -

enter image description here

You can update the code to alter color code(s) depending on your choice.

like image 90
Sujit Kumar Singh Avatar answered Sep 20 '22 02:09

Sujit Kumar Singh