def git_prompt(): """ Custom prompt that displays the name of the current git branch in addition to the typical "abbreviated current path" PyCmd prompt. Requires git & grep to be present in the PATH. """ # Many common modules (sys, os, subprocess, time, re, ...) are readily # shipped with PyCmd, you can directly import them for use in your # configuration script. If you need extra modules that are not bundled, # manipulate the sys.path so that they can be found (just make sure that the # version is compatible with the one used to build PyCmd -- check # README.txt) import subprocess stdout = subprocess.Popen( 'git branch | grep "^*"', shell=True, stdout=subprocess.PIPE, stderr=-1).communicate()[0] branch_name = stdout.strip(' \n\r*') abbrev_path = pycmd_public.abbrev_path() # The current color setting is defined by appearance.colors.prompt prompt = '' if branch_name != '': prompt += color.Fore.TOGGLE_BLUE + '[' + branch_name + ']' + color.Fore.TOGGLE_BLUE + ' ' prompt += abbrev_path + '> ' return prompt
def git_prompt(): """ Custom prompt that displays the name of the current git branch in addition to the typical "abbreviated current path" PyCmd prompt. Requires git & grep to be present in the PATH. """ # Many common modules (sys, os, subprocess, time, re, ...) are readily # shipped with PyCmd, you can directly import them for use in your # configuration script. If you need extra modules that are not bundled, # manipulate the sys.path so that they can be found (just make sure that the # version is compatible with the one used to build PyCmd -- check # README.txt) import subprocess stdout = subprocess.Popen('git branch | grep "^*"', shell=True, stdout=subprocess.PIPE, stderr=-1).communicate()[0] branch_name = stdout.strip(' \n\r*') abbrev_path = pycmd_public.abbrev_path() # The current color setting is defined by appearance.colors.prompt prompt = '' if branch_name != '': prompt += color.Fore.TOGGLE_BLUE + '[' + branch_name + ']' + color.Fore.TOGGLE_BLUE + ' ' prompt += abbrev_path + '> ' return prompt
def prompt(): # Use a tilde to represent our home dir path = re.sub(r"C:\\U\\j(oe)?", "~", abbrev_path()) username, is_admin = has_admin() path += '\n' if is_admin: path += color.Fore.TOGGLE_RED path += "# " path += color.Fore.TOGGLE_RED else: path += "$ " return path