Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion powerline_shell/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 6 additions & 1 deletion powerline_shell/segments/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@


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


Expand Down
8 changes: 4 additions & 4 deletions powerline_shell/segments/uptime.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ def add_to_powerline(self):
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:
Expand Down