aboutsummaryrefslogtreecommitdiffstats
path: root/epy.py
diff options
context:
space:
mode:
authorwustho <benawiadha@gmail.com>2020-04-19 11:45:25 +0700
committerwustho <benawiadha@gmail.com>2020-04-19 11:45:25 +0700
commite03619c5e80803e930b2e684a6116fbc83f336f9 (patch)
tree7054ff7a40682efcf62e0a35eae98f3590aa1de9 /epy.py
parent14a199b0f080a858797b1bdaf5665ee46bdff833 (diff)
downloadepy-e03619c5e80803e930b2e684a6116fbc83f336f9.tar.gz
Better display reading history.
Diffstat (limited to 'epy.py')
-rwxr-xr-xepy.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/epy.py b/epy.py
index 980e7ad..001b25f 100755
--- a/epy.py
+++ b/epy.py
@@ -1548,9 +1548,20 @@ def main():
if xitmsg != 0 or "-r" in args:
print("Reading history:")
dig = len(str(len(STATE["States"].keys())+1))
+ tcols, _ = shutil.get_terminal_size()
+ tcols -= dig + 2
+ tcolswdots = tcols - 3
+ tcolsa = 7 # tcolswdots//2
+ tcolsb = tcolswdots - tcolsa
for n, i in enumerate(STATE["States"].keys()):
- print(str(n+1).rjust(dig)
- + ("* " if STATE["LastRead"] == i else " ") + i)
+ # print(str(n+1).rjust(dig)
+ # + ("* " if STATE["LastRead"] == i else " ") + i)
+ p = i.replace(os.getenv("HOME"), "~")
+ print("{}{} {}".format(
+ str(n+1).rjust(dig),
+ "*" if i == STATE["LastRead"] else " ",
+ p if len(p) <= tcols else p[:tcolsa] + "..." + p[-tcolsb:]
+ ))
sys.exit(xitmsg)
if dump: