diff --git a/powerline_shell/__init__.py b/powerline_shell/__init__.py index ae62704..b0a4d2e 100644 --- a/powerline_shell/__init__.py +++ b/powerline_shell/__init__.py @@ -8,6 +8,8 @@ import importlib import json from .utils import warn, py3, import_file import re +import io +import platform def _current_dir(): @@ -238,5 +240,9 @@ def main(): segments.append(segment) for segment in segments: segment.add_to_powerline() + + if platform.system() == 'Windows': + sys.stdout = io.TextIOWrapper(sys.stdout.buffer, 'utf-8' , line_buffering = True) + sys.stdout.write(powerline.draw()) return 0 diff --git a/powerline_shell/segments/jobs.py b/powerline_shell/segments/jobs.py index e5d0551..72ced52 100644 --- a/powerline_shell/segments/jobs.py +++ b/powerline_shell/segments/jobs.py @@ -14,7 +14,7 @@ class Segment(ThreadedSegment): output = map(lambda l: int(l.split()[2].strip()), output_proc.communicate()[0].decode("utf-8").splitlines()[1:]) self.num_jobs = output.count(os.getppid()) - 1 - else: + elif platform.system() != 'Windows': pppid_proc = subprocess.Popen(['ps', '-p', str(os.getppid()), '-oppid='], stdout=subprocess.PIPE) pppid = pppid_proc.communicate()[0].decode("utf-8").strip()