This commit is contained in:
Miro 2026-05-21 20:08:00 +02:00 committed by GitHub
commit f4adda36ea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 6 deletions

View file

@ -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.

View file

@ -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

View file

@ -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: