mirror of
https://github.com/b-ryan/powerline-shell.git
synced 2026-09-10 07:26:28 -04:00
Merge 3d46519182 into 4b19aa47f1
This commit is contained in:
commit
f4adda36ea
|
|
@ -15,7 +15,7 @@ def _current_dir():
|
|||
in their shell (ie. without following symbolic links).
|
||||
|
||||
With the introduction of Bash for Windows, we can't use the PWD environment
|
||||
variable very easily. `os.sep` for windows is `\` but the PWD variable will
|
||||
variable very easily. `os.sep` for windows is `\\` but the PWD variable will
|
||||
use `/`. So just always use the `os` functions for dealing with paths. This
|
||||
also is fine because the use of PWD below is done to avoid following
|
||||
symlinks, which Windows doesn't have.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,12 @@ from ..utils import RepoStats, ThreadedSegment, get_git_subprocess_env
|
|||
|
||||
|
||||
def parse_git_branch_info(status):
|
||||
info = re.search('^## (?P<local>\S+?)''(\.{3}(?P<remote>\S+?)( \[(ahead (?P<ahead>\d+)(, )?)?(behind (?P<behind>\d+))?\])?)?$', status[0])
|
||||
branch_status = (
|
||||
r'^## (?P<local>\S+?)'
|
||||
r'(\.{3}(?P<remote>\S+?)'
|
||||
r'( \[(ahead (?P<ahead>\d+)(, )?)?(behind (?P<behind>\d+))?\])?)?$'
|
||||
)
|
||||
info = re.search(branch_status, status[0])
|
||||
return info.groupdict() if info else None
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -8,12 +8,12 @@ class Segment(BasicSegment):
|
|||
powerline = self.powerline
|
||||
try:
|
||||
output = decode(subprocess.check_output(['uptime'], stderr=subprocess.STDOUT))
|
||||
raw_uptime = re.search('(?<=up).+(?=,\s+\d+\s+user)', output).group(0)
|
||||
day_search = re.search('\d+(?=\s+day)', output)
|
||||
raw_uptime = re.search(r'(?<=up).+(?=,\s+\d+\s+user)', output).group(0)
|
||||
day_search = re.search(r'\d+(?=\s+day)', output)
|
||||
days = '' if not day_search else '%sd ' % day_search.group(0)
|
||||
hour_search = re.search('\d{1,2}(?=\:)', raw_uptime)
|
||||
hour_search = re.search(r'\d{1,2}(?=:)', raw_uptime)
|
||||
hours = '' if not hour_search else '%sh ' % hour_search.group(0)
|
||||
minutes = re.search('(?<=\:)\d{1,2}|\d{1,2}(?=\s+min)', raw_uptime).group(0)
|
||||
minutes = re.search(r'(?<=:)\d{1,2}|\d{1,2}(?=\s+min)', raw_uptime).group(0)
|
||||
uptime = u' %s%s%sm \u2191 ' % (days, hours, minutes)
|
||||
powerline.append(uptime, powerline.theme.CWD_FG, powerline.theme.PATH_BG)
|
||||
except OSError:
|
||||
|
|
|
|||
Loading…
Reference in a new issue