Improved function for git prompt and its width calculation