mirror of
https://github.com/b-ryan/powerline-shell.git
synced 2026-09-10 07:26:28 -04:00
Created vcs_newline.py
Only works with Git, for now
This commit is contained in:
parent
09fd45d6fc
commit
7a4f57798c
27
powerline_shell/segments/vcs_newline.py
Normal file
27
powerline_shell/segments/vcs_newline.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import subprocess
|
||||
from ..utils import RepoStats, ThreadedSegment, get_git_subprocess_env, warn
|
||||
|
||||
|
||||
def get_vcs_dir():
|
||||
return_code = subprocess.Popen("git status", shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True)
|
||||
return_code.communicate()[0].strip() # Blocks until 'git status' completes execution
|
||||
return return_code.returncode
|
||||
|
||||
|
||||
class Segment(ThreadedSegment):
|
||||
def run(self):
|
||||
self.in_vcs_dir = get_vcs_dir()
|
||||
|
||||
def add_to_powerline(self):
|
||||
self.join()
|
||||
if self.in_vcs_dir:
|
||||
return
|
||||
if self.powerline.args.shell == "tcsh":
|
||||
warn("newline segment not supported for tcsh (yet?)")
|
||||
return
|
||||
if self.powerline.segment_conf("vcs", "newline"):
|
||||
self.powerline.append("\n",
|
||||
self.powerline.theme.RESET,
|
||||
self.powerline.theme.RESET,
|
||||
separator="")
|
||||
|
||||
Loading…
Reference in a new issue