Why does my git shell look like this on my laptop: [name#name-Laptop ~ (master *+)]$, but not on desktop - bash

On my desktop, git looks like this:
On my laptop, git looks like this: [name#name-Laptop ~ (master *+)]$.
Here is an image to get a better idea of what git looks like on my laptop:
I have uninstalled and reinstalled git on my laptop, but after doing a normal setup as stated by multiple videos git always ends up as shown in the Incorrect Git.jpg file. How do I get git on my laptop to look like git on my desktop (Correct Git.jpg). I am using the VIM editor for both.
Any help would be much appreciated.

export PS1='\[\033]0;$TITLEPREFIX:$PWD\007\]\n\[\033[32m\]\u#\h \[\033[35m\]$MSYSTEM \[\033[33m\]\w\[\033[36m\]__git_ps1\[\033[0m\]\n$' is the solution.
So I found out that the PS1 was to configure the editor as William Pursell mentioned in the comments above. My configuration before was set up as [\u#\h \W$(_git_ps1 " (%s)")]\$. This gave me that white text for everything in git bash as shown above. By changing the PS1 to the configuration in my answer, I was able to get the colorful setup, shown above, for git bash on my laptop. I was able to get that long configuration by using echo "$PS1" and copied that over to my laptop. It looks much cleaner to me and is able to make navigation much easier. Also, thank you for the welcome!

Related

Git colors don't display in Windows command prompt

I assume that it's because of the color setting in my config file, but I've tried changing that to no avail. Maybe I'm not doing that right?
Notice that Git Bash shows branch color in green, but on window cl it's not showing at all!
$ git branch
* add_bower *<~~~ only the asterisk appears on the windows prompt.*
master
git in cmd should work just fine. I would check both your gitconfig local and gitconfig global before giving up here.
the first thing I would do is a
git branch --color
or
git diff --color
you can also use the -c option
git -c color.ui=always status
if you see colors then what is likely happening is your local gitconfig is overriding the setting in your global gitconfig
at that point do a
git config --local --edit
if things say auto or true and you still don't see colors. set the output to always. I recommend this b\c it is possible for git to make mistakes and not treat cmd as a terminal
from git-config:
If this is set to always, git-diff(1), git-log(1), and git-show(1)
will use color for all patches. If it is set to true or auto, those
commands will only use color when output is to the terminal. Defaults
to false.
like so
[color]
branch = always
diff = always
interactive = always
status = always
ui = always
hope this helps!
I don't think the command prompt will support coloring different parts of the output out of the box. You'd probably need some extension or add-on to handle it. Have you considered using Powershell? In addition to the built-in support for the coloring you're looking for, it's also much more versatile and powerful than the normal command prompt.
I'm seeing the exact same problem, only for some command prompts. (By default it works, but when I run my team's "razzle" customization script the output is broken like your screenshot. Oddly, coloring in git log and status works fine; just branch is broken.)
I created a new shortcut that launched the same customization script, and the output is fixed for my new shortcut. Very weird.
If you run git branch --no-color you see the right output, just without color?
You can run git config --local --add color.branch never to set that as the default for this repo.

How to get colored output with git+mintty+mingw on windows?

I have installed the official windows git distribution, and I installed a recent mingw, and into that the mintty terminal. Then I have copied my git installation to this mingw installation, and now it works from within mintty. My only problem is that the git output is not colored. I suspect that this is because the windows git port tries to use the windows console color thingie and not the ANSI color codes which mintty would be able to interpret. Is it possible to make git use the ANSI color codes instead?
(I have tried a cygwin setup prior to this, but the performance was very, very bad, and I could not find any solution to that).
from git-config:
If this is set to always, git-diff(1), git-log(1), and git-show(1) will use color for all patches. If it is set to true or auto, those commands will only use color when output is to the terminal. Defaults to false.
It looks like git isn't treat mintty as terminal. For me using always instead of true/auto helps:
[color]
status = always
Forcing color by adding --color flag to diff command work as well (with diff=true):
git diff --color
It's simple. Config git to always show color in any ui.
git config --global color.ui always
Works for me.

gitbash (cache passphrase key): Can't get the ssh-agent to run on windows, modified the .bashrc & .profile

can anyone help, i am on windows and git is working with my origin set to github.
Of course everytime i wish to pull / push or anything i need to supply the passphrase of the key for github.
According to what i have read i need to edit either a ~/.profile or ~/.bashrc and enter some text
see https://help.github.com/articles/working-with-ssh-key-passphrases
I have done this many times, i actually entered it in both files but when i open up a new GitBash windows nothing seems to run (i assume something is suppose to run and ask my for my passphrase according to the link above).
So of course every Push or Pull again asks me for the passphrase every single time.
I am obviosly missing something here can anyone help?
Remembering that i am on windows :-) and using gitbash that ships with git for windows.
Thanks in advance
Well after a lot of investigation, i found this Remember Password, Git bash under windows
which explains exactly what is needed, its different from linux it appears.
This might happen in case You've cloned the repository through the "https" method and now trying to do push/pull the "ssh" way or other way round.
See if this would work out for you :
git remote set-url origin git#github.com:your_account/your_repo.git
On Windows 10 this worked for me
run git bash
touch ~/.profile
start ~/.profile to open .profile
add the following to .profile
#! /bin/bash
eval `ssh-agent -s`
ssh-add ~/.ssh/*_rsa
This is based on this answer. The only difference is that .bashrc did not work, instead .profile worked.

Why does git diff on Windows warn that the "terminal is not fully functional"?

I'm using msysgit 1.7.7.1 on Windows. I get an error when using git diff. What is causing this? Is there no diff tool included in msysgit? What should I do?
WARNING: terminal is not fully functional
If you are having issues in cmd.exe, for instance, see the warning here:
Then simply set your environment variables and include TERM=msys. After that, each time you open a cmd.exe, your variable will be set correctly.
NOW YOU MUST RESTART YOUR SHELL (CMD.EXE). Just run a new one. And from there, you should have no more issues. Again:
For Git Bash, this can be fixed by adding the following line to ~/.bashrc:
export TERM=cygwin
-or-
export TERM=msys
The first seems to be the original by git for windows, the second a popular known form to "heal" as well.
The problem can be caused if some other program (like for example Strawberry Perl) sets the TERM system environment variables.
http://code.google.com/p/msysgit/issues/detail?id=184
Above answers was not fully worked for me, so I did:
Add
export TERM=msys
to "[githome]/etc/profile" at the top but it made changes only for git bash. Then I added
#set TERM=msys
to "[githome]/cmd/git.cmd" after #setlocal (I installed only git run from command line). May be this decision not truly good but it works for me and there are not any terminal warnings. (I use git version 1.7.10.msysgit.1).
The answer can be found here, in which the author of the solution claims that:
the environment variable TERM was set to dumb
that was instead of
TERM=cygwin
You can change that to
TERM=msys
to solve the problem at hand.
I work in powershell and I have the git executable directly in my path.
None of the suggested answers worked, but I found a solution that works for me.
I added a line in my powershell profile:
$env:TERM="msys"
Which fixed the problem for me.
A quick & dirty solution in my case turned out to be to use the --no-pager option.
By default, some git commands (like log) will use a pager like less if they expect the output to be long. Pagers require things like scrolling text up and down with the arrow keys, which sometimes doesn't work if the assumptions about what kind of terminal you're on are wrong (this is what the "not fully functional" means).
If you know ahead of time that your output will be short, or you just want it to dump output to the terminal and leave the scrolling up to your terminal program, you can override this and not use a pager at all, e.g.:
git --no-pager log
In case someone gets this launching bash from Git Extensions, check the setting for Path to linux tools.... Mine was set to C:\cygwin. Changing it to C:\Program Files (x86)\Git\bin\ fixed it for me. I didn't have to set the TERM variable to launch bash this way.

is there a way to add current working directory/current git repo/branch in terminal prompt for Mac

first time poster.
This came up in conversation at work this week...
Is there a way, when you connect to git remotely that you can get display current working directory/current git repo/branch in your terminal prompt?
Apparently, there are linux/vim scripts that exist for linux users, and I'd like to add this sort of shell script to my profile.
Currently I'm using some info from this page http://sos.blog-city.com/mac_os_x__bash_customize_your_terminal_prompt_a_little_color.htm to address some of this info locally.
Thanks in advance.
Get a copy of the git completion script. You can get this from git itself, or if you have a Linux box handy you could even just copy it from there (it'll probably be /etc/bash_completion.d/git). Then, arrange for this to get "sourced" by bash. You can do this by adding something like this to your .bashrc:
. /usr/local/git-completion
(assuming you named the file /usr/local/git-completion on your Mac).
Finally, you'll want to adjust your prompt. Also in your .bashrc, add something like:
export PS1='[\w$(__git_ps1 "|%s")]\$ '
Here's a blog post (not by me) that talks about this (and some other related stuff) in more detail: http://blog.bitfluent.com/post/27983389/git-utilities-you-cant-live-without
OK, I experimented with this after you pointed me in the right direction, my google searches got more refined results.
A lot of people point to the post you shared with me, like here: https://superuser.com/questions/31744/how-to-get-git-completion-bash-to-work-on-mac-os-x but I found some other jewels like these, which I didn't use but were informative: jeetworks.org/node/10 , jonmaddox.com/2008/03/13/show-your-git-branch-name-in-your-prompt/ .
I needed some different guidance on installing git.completion because I use homebrew which I found here: https://github.com/bobthecow/git-flow-completion/wiki/Install-Bash-git-completion which covers several ways to install it.
Finally, my bash/terminal has been a bit pokey so I upgraded to the latest bash with these instructions before I meshed with any of this: milkbox.net/brace_completion_snow_leopard_upgrading_bash/ and got some great speed improvement.
I ended up having to rebuild my profile script very carefully but with trail and error (because of differences between Bash 3 and 4, and some syntax errors)- now it looks great, and does the job.
Thanks again.
Sorry about above the security restraints of the site, restrict me (since I'm a newb) to 2 links to combat spam.
You just need 2 steps to do it.
Step.1:
Open ~/.bash_profile in your favorite editor and add the following content to the bottom.
For me it is like
emacs ~/.bash_profile
Step.2:
Add the following content to the bottom.
function git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'}
export PS1='\h:\w$(git_branch) \u\$'
Done!
P.s:
If you want your terminal colorful, try the following content.
export PS1 = '\[\e[1;39m\]\h:\w\[\e[01;39m\]$(git_branch) \[\e[01;39m\]$ \[\e[0m\]'
Another option to get git branch/status info in your shell prompt is to use powerline-shell.
You can see what this looks like in this screenshot:
The magenta/green bar is the current branch name. Its color indicates whether the working directory is clean. There are also markers that appear when there are untracked files, or when there are commits to be pulled-from/pushed-to the upstream remote.
Powerline-shell is compatible with bash, zsh, and fish.

Resources