mirror of
https://github.com/b-ryan/powerline-shell.git
synced 2026-09-10 07:26:28 -04:00
Merge f6de1c7fc2 into 4b19aa47f1
This commit is contained in:
commit
aea9983d79
33
powerline_shell/segments/vcs_newline.py
Normal file
33
powerline_shell/segments/vcs_newline.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import subprocess
|
||||
from ..utils import RepoStats, ThreadedSegment, get_git_subprocess_env, warn
|
||||
|
||||
|
||||
def get_vcs_dir():
|
||||
git_return_code = subprocess.Popen("git status", shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True)
|
||||
git_return_code.communicate()[0].strip() # Blocks until 'git status' completes execution
|
||||
hg_return_code = subprocess.Popen("hg status", shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True)
|
||||
hg_return_code.communicate()[0].strip() # Blocks until 'git status' completes execution
|
||||
svn_return_code = subprocess.Popen("svn info", shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True)
|
||||
svn_return_code.communicate()[0].strip() # Blocks until 'git status' completes execution
|
||||
if git_return_code.returncode==0 or hg_return_code.returncode==0 or svn_return_code.returncode==0:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
class Segment(ThreadedSegment):
|
||||
def run(self):
|
||||
self.in_vcs_dir = get_vcs_dir()
|
||||
|
||||
def add_to_powerline(self):
|
||||
self.join()
|
||||
if not self.in_vcs_dir:
|
||||
return
|
||||
if self.powerline.args.shell == "tcsh":
|
||||
warn("newline segment not supported for tcsh (yet?)")
|
||||
return
|
||||
self.powerline.append("\n",
|
||||
self.powerline.theme.RESET,
|
||||
self.powerline.theme.RESET,
|
||||
separator="")
|
||||
|
||||
Loading…
Reference in a new issue