Why Banking is No Ordinary Industry

Recent college graduates, many of whom have had little to no experience in managing an income, find themselves in the awkward position of having to do something with it; that is if we suppose they…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Style Your Command Prompt to Increase Productivity

We are all working on different projects, difference type of language, difference branch of your source, or the status of your commit on the current project. Style your command line prompt would probably help you increase your productivity. Let’s see the example.

It looks nice and simple, right? It tells you that you are under a node project, and it’s branch “master”, the node version is v9.7.1. It also tells you that your git status is ‘+’: there are new files, and ‘*’: there’re modifications. Let’s take a look at another project.

This example shows that you are working on a ruby or ruby on rails project, version is 2.3.0, and using branch test-command-prompt. You have modified a file and haven’t committed it yet. Fun? Right? Let’s go over this step by step.

First of all, you need to find the config file of you bash, and different OS, such as Mac OSX, or linux distribution may have different files based on your bash. Some are called .bashrc and some are called .profile under your home directory. In order to make the configuration more user friendly. Let’s define the color at the beginning of your shell configuration file.

Setup the Color Schema

Grab the Info of Coding Environment

In order to determine the project type, we are gonna need some commands whenever we enter a directory

Get the Git Status and Branch Name

And also, you will need some functions to determine the git branch name, commit status

Determine the Project Type

Now, how do I recognize what kind of project I’m working on. It’s simple. If there’s a Gemfile, then the project is ruby. If there’s package.json, I’ll assume it’s a node project, and the system will have different prompt. Let’s take a look

And also give the git different color to distinguish the master or other branches and also the *, -, +.

Now, everything is ready. Let’s put it together.

Now all set! You can find the source here.

Add a comment

Related posts:

The Great International Students

I was born and raised in Beijing, China. I didn’t go to an international school for a single day, finished my undergrad in Beijing, and moved to Canada for grad school when I just turned 22. Going…

Personalization Using Zoho CRM Targeting

Many online marketers using the increasingly popular Zoho CRM tool, a more affordable CRM with marketing automation tools, are looking to make maximum use of the customer data it contains, as they…

Piring

Aku takut dengan piring. Otakku tak pernah membiarkanku untuk melepaskan ingatan tentang piring. Tentang piring yang pecah, kemudian sisi tajamnya mengenai tanganku. Berdarah. Aku takut dengan…