Module: Yarsh::Prompt

Defined in:
lib/yarsh/prompt.rb

Class Method Summary collapse

Class Method Details

.basicObject



28
29
30
# File 'lib/yarsh/prompt.rb', line 28

def self.basic
  "#{Dir.pwd}> "
end

.powerlineObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/yarsh/prompt.rb', line 5

def self.powerline
  c = Yarsh::AnsiColorFormatter.new
  base_color = 240
  seg = Dir.pwd.gsub(/^#{Dir.home}/, '~').split('/')
  seg = (seg.size > 3 ? [''] + seg[-3..-1] : seg)
  git_branch = ''
  if File.directory?('.git')
    git_branch = `git status --porcelain -b`
                 .split("\n")
                 &.first
                 &.gsub('## ', '')
                 &.split('...', 2)
                 &.first || ''
  end
  git_branch = '  ' + git_branch unless git_branch.empty?
  c.bg_color256(base_color)
   .fg_white("#{seg.join('')}#{git_branch}")
   .reset
   .fg_color256(base_color, '')
   .reset(' ')
   .to_s
end