If you work with git, you’ve probably had that nagging sensation of not knowing what branch you are on. worry no longer! export ps1= ” \ w: $ (git branch 2>/dev/null grep ‘^*’ colrm 1 2) $ ” this will change your prompt to display not only your working directory but also your current git branch, if you have one. pretty nifty! ~/code/web:beta_directory$ git checkout master. Informative git prompt for bash and fish. this prompt is a port of the “informative git prompt for zsh” which you can find here. a bash prompt that displays information about the current git repository. in particular the branch name, difference with remote branch, number of files staged, changed, etc. So, if you wanted to add the date and time to your bash prompt and put the working directory on command on a second line, you could use the following construction: ps1=”[d t] u@hnw$ ” the square brackets here aren’t necessary at all, but help break things up visually and make the line easier to read. Another option is to use git bash prompt, install with this. i used the option via homebrew on mac os x. git_prompt_list_themes to see the themes but i didn’t like any of them. git_prompt_color_samples to see available colors. git_prompt_make_custom_theme [
You don’t need the line with the color/bash codes. here some links about how to change the colors and more info on the bash: bash prompt basics. bash prompt basics. linux command line by william shotts. i also included a link to a free ebook about the linux/unix terminal. Git 1. 9. 3 or later: use __git_ps1. git provides a shell script called git-prompt. sh, which includes a function __git_ps1 that. prints text to add to bash ps1 prompt (includes branch name) its most basic usage is:. First, i use prompt_command instead of ps1 to get coloured info, second i use add git status to bash prompt parse_git_branch { git branch 2> /dev/null .
Show Git Branch In Terminal Command Prompt Shellhacks
add git status to bash prompt parse_git_branch { git branch 2> /dev/null sed -e ‘/^ [^*]/d’ -e ‘s/* (. *)/ (1)/’ } export ps1=”u@h [ 33 [32m]w [ 33 [33m]$ (parse_git_branch) [ 33 [00m]n$ ” change terminal title prompt_command=’echo -ne “