Skip to content

icpd/robbyrussell.zsh-theme

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 

Repository files navigation

robbyrussell.zsh-theme

oh-my-zsh默认主题robbyrussell添加执行时间

Screenshot

Screenshot.png

Usage

wget -O ~/.oh-my-zsh/themes/robbyrussell.zsh-theme https://raw.githubusercontent.com/icpd/robbyrussell.zsh-theme/master/robbyrussell.zsh-theme

Other

修改其他主题其实原理都一样。在目标主题文件中添加以下代码:

function preexec() {
  timer=${timer:-$SECONDS}
}

function precmd() {
  if [ $timer ]; then
    timer_show=$(($SECONDS - $timer))
    if [[ $timer_show -ge $min_show_time ]]; then
      RPROMPT='%{$fg_bold[red]%}(${timer_show}s)%f%{$fg_bold[white]%}[%*]%f %{$reset_color%}%'
    else
      RPROMPT='%{$fg_bold[white]%}[%*]%f'
    fi
    unset timer
  fi
}

autoload -Uz add-zsh-hook
add-zsh-hook preexec preexec
add-zsh-hook precmd precmd

About

ohmyzsh robbyrussell theme add execution time

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages