diff --git a/main.py b/main.py index da838c0..11ad5fb 100644 --- a/main.py +++ b/main.py @@ -11,15 +11,15 @@ def completer(text, state): matches = [cmd for cmd in commands + local_files if cmd.startswith(text)] return matches[state] if state < len(matches) else None -# 获取真正的 Last login 信息 -def get_last_login(): - try: - # 使用 `last` 命令获取登录信息 - result = subprocess.run(['last', '-1'], stdout=subprocess.PIPE, text=True) - last_login_line = result.stdout.splitlines()[0] # 获取第一行 - return last_login_line - except Exception as e: - return "Last login: unknown" # 如果出错,返回默认值 +# # 获取真正的 Last login 信息 +# def get_last_login(): +# try: +# # 使用 `last` 命令获取登录信息 +# result = subprocess.run(['last', '-1'], stdout=subprocess.PIPE, text=True) +# last_login_line = result.stdout.splitlines()[0] # 获取第一行 +# return last_login_line +# except Exception as e: +# return "Last login: unknown" # 如果出错,返回默认值 # 模拟一个简单的 zsh 终端 def pseudo_zsh(): @@ -31,7 +31,7 @@ def pseudo_zsh(): os.system("clear") # 清屏 subprocess.run("cd /", shell=True) # 切换到用户目录 - print(f"{get_last_login()} on ttys000") + print(f"Last login: {datetime.now().strftime('%a %b %d %H:%M:%S %Y')} on ttys000") while True: try: