Exemplo n.º 1
0
def print_warning(text):
    from utils import colors
    from utils.glyphs import ESCLAMATION
    from segments.basics import Divider

    divider = Divider()
    cross_rendered = '{}{} {}{}{}{}'.format(
        colors.background(colors.GOLD),
        ESCLAMATION,
        colors.reset(),
        colors.foreground(colors.GOLD),
        divider.text if divider.active else '',
        colors.reset()
    )

    text_rendered = '{}{}promptastic{}: {}{}\n'.format(
        colors.foreground(colors.LIGHTER_GOLD),
        colors.underline_start(),
        colors.underline_end(),
        text,
        colors.reset()
    )

    output = '{} {}'.format(cross_rendered, text_rendered)
    print_raw(output)
Exemplo n.º 2
0
class UserAtHost(Segment):
    bg = colors.background(theme.USERATHOST_BG)
    fg = colors.foreground(theme.USERATHOST_FG)

    def init(self):
        self.text = '{}@{}'.format(getpass.getuser(),
                                   socket.gethostname().replace('.local', ''))
Exemplo n.º 3
0
class CurrentDir(Segment):
    bg = colors.background(theme.CURRENTDIR_BG)
    fg = colors.foreground(theme.CURRENTDIR_FG)

    def init(self, cwd):
        home = os.path.expanduser('~')
        self.text = cwd.replace(home, '~')
Exemplo n.º 4
0
def print_warning(text):
    from utils import colors
    from utils.glyphs import ESCLAMATION
    from segments.basics import Divider

    divider = Divider()
    cross_rendered = '{}{} {}{}{}{}'.format(
        colors.background(colors.GOLD), ESCLAMATION, colors.reset(),
        colors.foreground(colors.GOLD), divider.text if divider.active else '',
        colors.reset())

    text_rendered = '{}{}promptastic{}: {}{}\n'.format(
        colors.foreground(colors.LIGHTER_GOLD), colors.underline_start(),
        colors.underline_end(), text, colors.reset())

    output = '{} {}'.format(cross_rendered, text_rendered)
    print_raw(output)
Exemplo n.º 5
0
class Time(Segment):
    bg = colors.background(theme.TIME_BG)
    fg = colors.foreground(theme.TIME_FG)

    def init(self):
        now = datetime.now().time()
        self.text = '{} {}:{}:{}'.format(glyphs.TIME, now.hour, now.minute,
                                         now.second)
Exemplo n.º 6
0
class ExitCode(Segment):
    bg = colors.background(theme.EXITCODE_BG)
    fg = colors.foreground(theme.EXITCODE_FG)

    def init(self):
        self.text = ' ' + glyphs.CROSS + ' '

        if sys.argv[1] == '0':
            self.active = False
Exemplo n.º 7
0
class ReadOnly(Segment):
    bg = colors.background(theme.READONLY_BG)
    fg = colors.foreground(theme.READONLY_FG)

    def init(self, cwd):
        self.text = ' ' + glyphs.WRITE_ONLY + ' '

        if os.access(cwd, os.W_OK):
            self.active = False
Exemplo n.º 8
0
class Ssh(Segment):
    bg = colors.background(theme.SSH_BG)
    fg = colors.foreground(theme.SSH_FG) + colors.bold()

    def init(self):
        self.text = 'SSH'

        if not os.getenv('SSH_CLIENT'):
            self.active = False
Exemplo n.º 9
0
class Venv(Segment):
    bg = colors.background(theme.VENV_BG)
    fg = colors.foreground(theme.VENV_FG)

    def init(self):
        env = os.getenv('VIRTUAL_ENV')
        if env is None:
            self.active = False
            return

        env_name = os.path.basename(env)
        self.text = glyphs.VIRTUAL_ENV + ' ' + env_name
Exemplo n.º 10
0
    def init(self):
        branch_name = self.get_branch_name()

        if not branch_name:
            self.active = False
            return

        self.git_status_output = self.get_git_status_output()

        wd_glyph, git_colors = self.get_working_dir_status_decorations()
        self.bg = colors.background(git_colors[0])
        self.fg = colors.foreground(git_colors[1])

        current_commit_text = self.get_current_commit_decoration_text()
        self.text = wd_glyph + ' ' + branch_name + glyphs.BRANCH + ' ' + current_commit_text
Exemplo n.º 11
0
    def init(self):
        branch_name = self.get_branch_name()

        if not branch_name:
            self.active = False
            return

        self.git_status_output = self.get_git_status_output()

        wd_glyph, git_colors = self.get_working_dir_status_decorations()
        self.bg = colors.background(git_colors[0])
        self.fg = colors.foreground(git_colors[1])

        current_commit_text = self.get_current_commit_decoration_text()
        self.text = wd_glyph + ' ' + branch_name + glyphs.BRANCH + ' ' + current_commit_text
Exemplo n.º 12
0
class Jobs(Segment):
    bg = colors.background(theme.JOBS_BG)
    fg = colors.foreground(theme.JOBS_FG)

    def init(self):
        pppid = subprocess.Popen(
            ['ps', '-p', str(os.getppid()), '-oppid='],
            stdout=subprocess.PIPE).communicate()[0].strip()
        output = subprocess.Popen(['ps', '-a', '-o', 'ppid'],
                                  stdout=subprocess.PIPE).communicate()[0]
        num_jobs = len(re.findall(bytes(pppid), output)) - 1

        self.text = '{} {}'.format(glyphs.HOURGLASS, num_jobs)

        if not num_jobs:
            self.active = False
Exemplo n.º 13
0
class Time(Segment):
    bg = colors.background(theme.TIME_BG)
    fg = colors.foreground(theme.TIME_FG)

    def init(self):
        self.text = glyphs.TIME + ' ' + str(time.strftime("%H:%M:%S"))
Exemplo n.º 14
0
class Time(Segment):
    bg = colors.background(theme.TIME_BG)
    fg = colors.foreground(theme.TIME_FG)

    def init(self):
        self.text = '{} {}'.format(glyphs.TIME, time.strftime("%H:%M:%S"))