Skip to content

venkat-r-r/terminal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 

Repository files navigation

Display current git branch name in terminal or integrated terminal in VS code

step 1: create a file as .zshrc in Users/your_name/ directory and open it using TextEditor (note: no need to create if already exist)

step 2: paste the below code at the end of that file and save it

function git_branch_name()
{
  branch=$(git symbolic-ref HEAD 2> /dev/null | awk 'BEGIN{FS="/"} {print $NF}')
  if [[ $branch == "" ]];
  then
    :
  else
    echo ' %F{cyan}('$branch')%f'
  fi
}

setopt prompt_subst;

PS1="%K{default}%F{magenta}%B%1~%b%f"'$(git_branch_name)'"%k %# "

step 3: restart your terminal/integrated-terminal to see the changes

Screenshot 2022-06-25 at 9 53 30 AM

To customise the style

Refer to this zsh site and change the PS1 value according to your choice

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published