fix PathPart behavior below symlinked directories
This commit is contained in:
parent
87cec89722
commit
50a5d88b42
2 changed files with 13 additions and 13 deletions
|
@ -110,20 +110,20 @@ class Sysload:
|
||||||
self.load15 = float(loadavg[2]) / cores
|
self.load15 = float(loadavg[2]) / cores
|
||||||
self.tasks_ready, self.tasks_total = [int(x) for x in loadavg[3].split("/")]
|
self.tasks_ready, self.tasks_total = [int(x) for x in loadavg[3].split("/")]
|
||||||
|
|
||||||
|
|
||||||
class Settings:
|
class Settings:
|
||||||
def __init__(self, argv):
|
def __init__(self, argv):
|
||||||
try:
|
try:
|
||||||
self.term_width = int(argv[1])
|
self.term_width = int(argv[1])
|
||||||
self.last_refresh_time = int(argv[2]) if argv[2] else None
|
self.cwd = argv[2]
|
||||||
self.load_warn = float(argv[3])
|
self.last_refresh_time = int(argv[3]) if argv[3] else None
|
||||||
self.load_error = float(argv[4])
|
self.load_warn = float(argv[4])
|
||||||
self.space_warn = float(argv[5])
|
self.load_error = float(argv[5])
|
||||||
self.space_error = float(argv[6])
|
self.space_warn = float(argv[6])
|
||||||
|
self.space_error = float(argv[7])
|
||||||
self.is_root = os.geteuid() == 0
|
self.is_root = os.geteuid() == 0
|
||||||
except:
|
except:
|
||||||
print("Usage: %s $COLUMNS last_refresh_time load_warn load_error space_warn space_error")
|
print("Usage: %s $COLUMNS $PWD last_refresh_time load_warn load_error space_warn space_error")
|
||||||
print(" e.g. %s 1 $COLUMNS 25 1.25 2.5 0.15 0.05")
|
print(" e.g. %s 1 $COLUMNS $PWD 25 1.25 2.5 0.15 0.05")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
raise
|
raise
|
||||||
|
@ -261,13 +261,13 @@ class PathPart(Part):
|
||||||
|
|
||||||
Contructs a list of Dirs from the root to CWD. When fit is called, some Dirs may be shortened.
|
Contructs a list of Dirs from the root to CWD. When fit is called, some Dirs may be shortened.
|
||||||
"""
|
"""
|
||||||
def __init__(self, term_width):
|
def __init__(self, settings):
|
||||||
Part.__init__(self)
|
Part.__init__(self)
|
||||||
self.term_width = term_width
|
self.term_width = settings.term_width
|
||||||
self.dirs = []
|
self.dirs = []
|
||||||
|
|
||||||
homes = dict(list_homes())
|
homes = dict(list_homes())
|
||||||
dirs = os.getcwd().split("/")[1:]
|
dirs = settings.cwd.split("/")[1:]
|
||||||
path = ""
|
path = ""
|
||||||
|
|
||||||
for dir in dirs:
|
for dir in dirs:
|
||||||
|
@ -529,7 +529,7 @@ if __name__ == "__main__":
|
||||||
sysload = Sysload()
|
sysload = Sysload()
|
||||||
|
|
||||||
lp = LoginPart(settings, sysload)
|
lp = LoginPart(settings, sysload)
|
||||||
pp = PathPart(settings.term_width)
|
pp = PathPart(settings)
|
||||||
gp = GitPart()
|
gp = GitPart()
|
||||||
pad = Padding(settings.term_width)
|
pad = Padding(settings.term_width)
|
||||||
sp = StatsPart(settings, sysload)
|
sp = StatsPart(settings, sysload)
|
||||||
|
|
|
@ -21,7 +21,7 @@ function preexec {
|
||||||
|
|
||||||
function precmd {
|
function precmd {
|
||||||
set_title "${PWD}"
|
set_title "${PWD}"
|
||||||
python3 /usr/libexec/over-prompt.py "${COLUMNS}" "${OVER_PROMPT_LAST_REFRESH}" "${OVER_PROMPT_SYSLOAD_WARN:=1.25}" "${OVER_PROMPT_SYSLOAD_YELL:=2.5}" "${OVER_PROMPT_FREESPACE_WARN:=0.15}" "${OVER_PROMPT_FREESPACE_YELL:=0.05}"
|
python3 /usr/libexec/over-prompt.py "${COLUMNS}" "${PWD}" "${OVER_PROMPT_LAST_REFRESH}" "${OVER_PROMPT_SYSLOAD_WARN:=1.25}" "${OVER_PROMPT_SYSLOAD_YELL:=2.5}" "${OVER_PROMPT_FREESPACE_WARN:=0.15}" "${OVER_PROMPT_FREESPACE_YELL:=0.05}"
|
||||||
PS1="$(print "%(?.%{\e[1;36m%}.%{\e[1;31m%}%?%{\e[0m%}:%{\e[1;31m%})%(\!.#.$)%{\e[0m%} ")"
|
PS1="$(print "%(?.%{\e[1;36m%}.%{\e[1;31m%}%?%{\e[0m%}:%{\e[1;31m%})%(\!.#.$)%{\e[0m%} ")"
|
||||||
OVER_PROMPT_LAST_REFRESH=$(date +%s)
|
OVER_PROMPT_LAST_REFRESH=$(date +%s)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue