Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- _prompt_arthur_pwd=''
- _prompt_arthur_start_time=0
- _prompt_arthur_elapsed_printed=''
- prompt_arthur_print_elapsed_time() {
- $_prompt_arthur_elapsed_printed && return
- local t=$(( SECONDS - _prompt_arthur_start_time ))
- local h m s r
- if (( t >= 3600 )); then
- h=$(( t / 3600 ))
- r=$(( t % 3600 ))
- m=$(( r / 60 ))
- s=$(( r % 60 ))
- print -P "%B%F{red}elapsed time ${h}h${m}m${s}s%b"
- elif (( t >= 60 )); then
- m=$(( t / 60 ))
- s=$(( t % 60 ))
- print -P "%B%F{yellow}elapsed time ${m}m${s}s%b"
- elif (( t > 1 )); then
- print -P "%B%F{green}elapsed time ${t}s%b"
- fi
- _prompt_arthur_elapsed_printed=true
- }
- function prompt_arthur_precmd {
- setopt LOCAL_OPTIONS
- unsetopt XTRACE KSH_ARRAYS
- _prompt_arthur_pwd=$(prompt-pwd)
- prompt_arthur_print_elapsed_time
- }
- function prompt_arthur_preexec {
- _prompt_arthur_start_time=$SECONDS
- _prompt_arthur_elapsed_printed=false
- }
- function prompt_arthur_setup {
- setopt LOCAL_OPTIONS
- unsetopt XTRACE KSH_ARRAYS
- prompt_opts=(cr percent sp subst)
- autoload -Uz add-zsh-hook
- add-zsh-hook preexec prompt_arthur_preexec
- add-zsh-hook precmd prompt_arthur_precmd
- _prompt_arthur_pwd=''
- PROMPT='%B${_prompt_arthur_pwd}%b '
- RPROMPT=''
- }
- prompt_arthur_setup "$@"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement