Reputation: 45
As we all know, we can modify the "PS1" variable to change the prompt of our terminal on Linux or MAC OS, I have changed "PS1" variable to
PS1="\[\033[0;37;40m\u@\033[0;36;40m\h:\033[0;35;40m\w$\033[0m^.^\t \]"
, and my prompt of terminal can display like this.
the time will be updated after I press "enter" button, now I want to let the time string can update automatically in a single line.How can I do this?I use bash.
Upvotes: 0
Views: 1086
Reputation: 2547
If you are using zsh
shell
edit ~/.zshrc
adding the following lines:
setopt PROMPT_SUBST
PROMPT='%B%F{red}%n@%m%f%F{yellow}[%D{%L:%M:%S}]%f:%F{blue}${${(%):-%~}}%f$ %b'
TMOUT=1
TRAPALRM() {
zle reset-prompt
}
Save and then update your terminal with source .zshrc
Upvotes: 1