Skip to content

Commit

Permalink
Merge pull request #366 from Blue-Dog-Archolite/master
Browse files Browse the repository at this point in the history
Ruby Segment changes for Python 2/3:
  • Loading branch information
b-ryan authored Feb 23, 2018
2 parents f6c7eaa + 6ff4b50 commit da8d923
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions powerline_shell/segments/ruby_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@
class Segment(BasicSegment):
def add_to_powerline(self):
powerline = self.powerline

try:
p1 = subprocess.Popen(["ruby", "-v"], stdout=subprocess.PIPE)
p2 = subprocess.Popen(["sed", "s/ (.*//"], stdin=p1.stdout, stdout=subprocess.PIPE)
version = p2.communicate()[0].decode("utf-8").rstrip()
if os.environ.has_key("GEM_HOME"):
gem = os.environ["GEM_HOME"].split("@")
if len(gem) > 1:
version += " " + gem[1]
powerline.append(version, 15, 1)
p1 = subprocess.Popen(['ruby', '-v'], stdout=subprocess.PIPE)
p2 = subprocess.Popen(['sed', "s/ (.*//"], stdin=p1.stdout, stdout=subprocess.PIPE)
ruby_and_gemset = p2.communicate()[0].decode('utf-8').rstrip()

gem_set = os.environ.get('GEM_HOME', '@').split('@')

if len(gem_set) > 1:
ruby_and_gemset += "@{}".format(gem_set.pop())

powerline.append(ruby_and_gemset, 15, 1)
except OSError:
return

0 comments on commit da8d923

Please sign in to comment.