macos - 如何将执行命令的时间添加到 Mac 上的终端? (改变格式)

标签 macos bash

我的终端行的默认格式如下所示:

David-Mac-mini:~ david$

如果有一种方法可以让它默认显示为:

David-Mac-mini:~ david$ [Hh:Mm:Ss]

最佳答案

您已编辑或创建您的 .bashrc 或 .bash_profile 配置文件。 添加命令 export PS1="\t"

您可以添加以下行来自定义您的终端提示:

\d – Current date
\t – Current time
\h – Host name
\# – Command number
\u – User name
\W – Current working directory (ie: Desktop/)
\w – Current working directory with full path (ie: /Users/Admin/Desktop/)

关于macos - 如何将执行命令的时间添加到 Mac 上的终端? (改变格式),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36503861/

相关文章:

bash - 脚本,将所有 $input 保存到 1 个变量中

macos - 自动打开目录 (mac os x) 和创建 m3u 播放列表的脚本

macos - 自定义登录屏幕 Mac OSX (SFAuthorizationPluginView)

c++ - g++ 在应该产生错误时没有产生错误,例如 "error: variable length array of non-POD element type"

cocoa - 从菜单中选择项目时,自定义 NSCell 内的 NSPopUpButtonCell 不会更改选择

c++ - 我可以使用哪种 C++ 软件 IDE 来面向 Windows、Linux 和 OSX?

linux - GNU 并行负载均衡

bash - 提取 ping 时间并使用时间戳作为前缀

macos - Automator 中的 Shell 脚本不起作用

bash - 如何输出按用户排序的命令列表?