该脚本中设置提示的时间戳在哪里?

小丑

我碰到了这个老帖子,发现对我很有用。现在,我正在努力,但徒劳地告诉它哪一部分负责在破折号的末尾打印时间戳。

以下是便于参考的脚本:

# Fill with minuses
# (this is recalculated every time the prompt is shown in function prompt_command):
fill="—- "
reset_style='\[\033[00m\]'
status_style=$reset_style'\[\033[0;90m\]' # gray color; use 0;37m for lighter color
prompt_style=$reset_style
command_style=$reset_style'\[\033[1;29m\]' # bold black

# Prompt variable:
PS1="$status_style"'$fill \t\n'"$prompt_style"'${debian_chroot:+($debian_chroot)}\u@\h:\w\$'"$command_style "

# Reset color for command output
# (this one is invoked every time before a command is executed):
trap 'echo -ne "\e[0m"' DEBUG

function prompt_command {
    # create a $fill of all screen width minus the time string and a space:
    let fillsize=${COLUMNS}-9
    fill=""
    while [ "$fillsize" -gt "0" ]
    do
        fill="-${fill}" # fill with underscores to work on
        let fillsize=${fillsize}-1
    done

    # If this is an xterm set the title to user@host:dir
    case "$TERM" in
    xterm*|rxvt*)
        bname=`basename "${PWD/$HOME/~}"`
        echo -ne "\033]0;${bname}: ${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"
        ;;
    *)
        ;;
    esac
}

PROMPT_COMMAND=prompt_command

有什么提示吗?

赞娜

\t是组成整个提示的这一行,其中包含fill已分配的变量(包括破折号)。

PS1="$status_style"'$fill \t\n'"$prompt_style"'${debian_chroot:+($debian_chroot)}\u@\h:\w\$'"$command_style "

在中PS1\t显示当前时间Bash转义序列

测试:

zanna@toaster:~$ PS1="\t"
21:33:06

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

该环境变量在哪里设置?

来自分类Dev

Atom中的“脚本”在哪里?

来自分类Dev

在终端提示中添加时间戳?

来自分类Dev

在终端提示中添加时间戳?

来自分类Dev

Safari中存储的Tampermonkey脚本在哪里

来自分类Dev

Linux中alias命令的脚本在哪里?

来自分类Dev

VSCode中的配置设置在哪里?

来自分类Dev

FreeNAS中的代理设置在哪里?

来自分类Dev

ubuntu 18.04中的主题设置在哪里?

来自分类Dev

Ubuntu 19.04 中的 mozc 设置在哪里?

来自分类Dev

在belongsToMany 中设置字段的名称在哪里?

来自分类Dev

cosmosdb 设置中的主机 azure 在哪里?

来自分类Dev

在corda中在哪里设置共识算法?

来自分类Dev

zsh 在哪里存储时间戳和执行时间

来自分类Dev

Magento 2中的模板路径提示在哪里?

来自分类Dev

动作脚本在哪里?

来自分类Dev

时间在哪里缓存

来自分类Dev

Linux中存储的文件创建时间(出生时间)在哪里?

来自分类Dev

如何正确设置当前时间戳到此Java CRUD方法中,该方法将值插入MySql表中?

来自分类Dev

在onLocationChanged方法中设置时间戳

来自分类Dev

在 PhpMyAdmin 中设置自动时间戳

来自分类Dev

MySQL中的FORCE INDEX-该放在哪里?

来自分类Dev

该交换文件在/ etc / fstab中的位置在哪里

来自分类Dev

在哪里设置PublishReadyToRun?

来自分类Dev

声音设置在哪里?

来自分类Dev

该TrySZBinarySearch在哪里实现?

来自分类Dev

在哪里引用Angular App中的controller.js脚本

来自分类Dev

在哪里将freeze_support()放在Python脚本中?

来自分类Dev

tensorflow中的gen_math_ops脚本在哪里?