def user_prompt(): try: uid = os.getuid() username = pwd.getpwuid(uid).pw_name except KeyError: uid = 0 username = '******' return fgcolor('%s@%s' % (username, os.uname()[1].replace('.local', '')), uid == 0 and 'red' or 'brown', light=True)
def prompt(): version_control = vc_prompt() virtualenv = virtualenv_prompt() fabfile = fabfile_prompt() ps1 = r'\n%s%s%s%s%s%s\n%s' % ( fgcolor(fabfile and r'%s\n' % fabfile or '', 'cyan'), fgcolor(virtualenv and r'%s\n' % virtualenv or '', 'purple', light=True), fgcolor(version_control and r'%s ' % version_control or '', 'green'), fgcolor(user_prompt(), 'brown', light=True), fgcolor(':', 'white'), fgcolor(directory_prompt()), fgcolor('$ ', 'black', light=True), ) return 'export PS1="%s";' % _shell_escape(ps1)
def directory_prompt(): return fgcolor(os.path.abspath(os.curdir), 'blue', light=True)