3 de agosto de 2015

Setting sail towards an awesome GIT experience

Here goes a bundle of tricks and treats for a better GIT experience:

Some years ago I found something like that I'm going to show you and, eventually, I assembled a series of scripts (some things I did, some things that I found on the web); they do various things with bash, which are sweet.

What things?


  • Automatically detects if you are in a folder belonging to a git repo, and, in the case it is, the prompt display relevant information that is repo: branch and state. Example:




In this case depicted, I was on the branch "master" and I had modified files (hence the "m") and files I deleted (hence the "d").


  •  Another cool thing is to have tab completion (that pressing the tab key with a half-written command you get all the options to complete the command -or the command being automatically completed if there was just one choice-).


Imagine that applied to branch names, git commands and Django commands (like "python manage.py runserver" for example). Sweet, isn't it?


  • Some other sweetnesses included:
    • Increase the size of the history of bash, but eliminating duplicates, so to do "ctrl r" in the console, we can look at the history of the commands that we did and found interesting results.
    • A long list of colors defined to directly save them in defining the prompt.
    • Etc!

The scripts, give me the scripts!

The first two put them right into your home folder.
The third file, call it the way your system get it right. For me it is .bash_profile. Put it right in your home with this name or copy its contents to your existing bash config file.
If you use Linux, you can do the same with .bashrc.

Note that the files have an underscore in the beginning of their filenames. Remove this underscore when placing the files, letting the names begin with a dot, as they are hidden files.


Cheers and May the bash be with you!!