githubteacher / fluffy-octo-guacamole

demo and practice repo for May 2016 GitHub for Developers class
14 stars 15 forks source link

Git Tweaks on Mac Command Line #258

Closed mixolidia closed 8 years ago

mixolidia commented 8 years ago

Hi,

I'm hoping to add some of the terminal tweaks I see @githubteacher has on their terminal.

My command line shows me the name of my computer and directory I'm in like this: screen shot 2016-05-12 at 12 15 08 pm

How do I have my terminal show the current branch I'm in along with the information it is already showing, my computer name and directory?

Also, when I press the tab key on my terminal it completes the file or folder name but not the git branch I want to check out to, how do I get it to complete the branch name when I press the Tab key?

Thanks :octocat:s

brianamarie commented 8 years ago

@mixolidia 👋 I love that you included a tag on this!!!

Here is the info you should need -

Useful Bits

To print the name of your currently checked out branch in your prompt, include this line as part of your PS1:

git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'

Extras

A few people also asked about @patrickmckenna's Terminal.app theme. He uses ocean-terminal. His PS1 (prompt) is

export PS1="\[\$(tput bold)\]\[\$(tput setaf 6)\]\w\[\$(tput setaf 3)\]\$(git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/')\[\$(tput setaf 6)\] > \[\$(tput sgr0)\]"
brianamarie commented 8 years ago

I'm going to close this issue, hopefully all is working well. Please feel free to comment here again if you are having issues. Or, let us know in gitter: https://gitter.im/githubteacher/fluffy-octo-guacamole 😄

mixolidia commented 8 years ago

Hi @brianamarie Thanks! I'll try it during the next break & let you know how it works out.

mixolidia commented 8 years ago

Thanks for the <3 on my tag 😀 . What's a PS1?

brianamarie commented 8 years ago

@mixolidia PS1 is a *nix command prompt. If you are using windows, and you use Git Bash, you'll automatically get the branch names. Does that make sense?

brianamarie commented 8 years ago

@mixolidia This may be a bit more thorough of an explanation: https://gist.github.com/githubteacher/e75edf29d76571f8cc6c