Exemplo n.º 1
0
def get_prompt_state():
    full_cwd = os.getcwd()
    cwd_raw = full_cwd.replace(env['HOME'], '~')
    dir_raw = '~' if full_cwd == env['HOME'] else os.path.split(full_cwd)[-1]
    return {
        'user': TermString(getpass.getuser()),
        'cwd': TermString(cwd_raw),
        'dir': TermString(dir_raw),
        'hostname': TermString(socket.gethostname()),
        'git_branch': _branch_to_term_string(get_current_git_branch()),
        'hg_id': TermString(get_current_hg_id()),
        'hg_branch': _branch_to_term_string(get_current_hg_branch()),
        'hg_bookmark': TermString(get_current_hg_bookmark()),
        'vcs_branch': _branch_to_term_string(get_current_vcs_branch()),
        # Symbols
        'r_angle': R_ANGLE,
        'r_angle_double': R_ANGLE_DOUBLE,
        'r_arrow': R_ARROW,
        'dollar': DOLLAR,
        'percent': PERCENT,
        'now': dt.datetime.now(),
        'new_line': NEW_LINE,
        'nl': NEW_LINE,
        # ANSI values object
        'TTY': TTY,
    }
Exemplo n.º 2
0
def get_prompt_state():
    full_cwd = os.getcwd()
    home = env.get("HOME", "")
    cwd_raw = full_cwd.replace(home, "~")
    dir_raw = "~" if full_cwd == home else os.path.split(full_cwd)[-1]
    return {
        "user": TermString(getpass.getuser()),
        "cwd": TermString(cwd_raw),
        "dir": TermString(dir_raw),
        "hostname": TermString(socket.gethostname()),
        "git_branch": _branch_to_term_string(get_current_git_branch()),
        "hg_id": TermString(get_current_hg_id()),
        "hg_branch": _branch_to_term_string(get_current_hg_branch()),
        "hg_bookmark": TermString(get_current_hg_bookmark()),
        "vcs_branch": _branch_to_term_string(get_current_vcs_branch()),
        # Symbols
        "r_angle": R_ANGLE,
        "r_angle_double": R_ANGLE_DOUBLE,
        "r_arrow": R_ARROW,
        "dollar": DOLLAR,
        "percent": PERCENT,
        "now": dt.datetime.now(),
        "new_line": NEW_LINE,
        "nl": NEW_LINE,
        # ANSI values object
        "TTY": TTY,
    }