5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# 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 = ''
git_branch = `git status --porcelain -b`.split("\n")&.first&.gsub('## ', '') || '' if File.directory?('.git')
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
|