Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
ff7618cf
Unverified
Commit
ff7618cf
authored
Jul 14, 2020
by
Frederick Zhang
Committed by
GitHub
Jul 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
timer: threshold to show timers only for time-consuming commands (#8151)
parent
68b98c9d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
3 deletions
+6
-3
README.md
plugins/timer/README.md
+1
-0
timer.plugin.zsh
plugins/timer/timer.plugin.zsh
+5
-3
No files found.
plugins/timer/README.md
View file @
ff7618cf
...
@@ -3,6 +3,7 @@ This plugin allows to display command's execution time in a very nonintrusive wa
...
@@ -3,6 +3,7 @@ This plugin allows to display command's execution time in a very nonintrusive wa
Timer can be tuned by these two variables:
Timer can be tuned by these two variables:
*
`TIMER_PRECISION`
allows to control number of decimal places (default
`1`
)
*
`TIMER_PRECISION`
allows to control number of decimal places (default
`1`
)
*
`TIMER_FORMAT`
allows to adjust display format (default
`'/%d'`
)
*
`TIMER_FORMAT`
allows to adjust display format (default
`'/%d'`
)
*
`TIMER_THRESHOLD`
allows to set the minimum execution time that causes the timer to be shown (default
`0`
)
Sample session:
Sample session:
...
...
plugins/timer/timer.plugin.zsh
View file @
ff7618cf
...
@@ -19,9 +19,11 @@ __timer_display_timer_precmd() {
...
@@ -19,9 +19,11 @@ __timer_display_timer_precmd() {
local
cmd_end_time
=
$(
__timer_current_time
)
local
cmd_end_time
=
$(
__timer_current_time
)
local
tdiff
=
$((
cmd_end_time
-
__timer_cmd_start_time
))
local
tdiff
=
$((
cmd_end_time
-
__timer_cmd_start_time
))
unset
__timer_cmd_start_time
unset
__timer_cmd_start_time
local
tdiffstr
=
$(
__timer_format_duration
${
tdiff
})
if
[[
-z
"
${
TIMER_THRESHOLD
}
"
||
${
tdiff
}
-ge
"
${
TIMER_THRESHOLD
}
"
]]
;
then
local
cols
=
$((
COLUMNS
-
${#
tdiffstr
}
-
1
))
local
tdiffstr
=
$(
__timer_format_duration
${
tdiff
})
echo
-e
"
\0
33[1A
\0
33[
${
cols
}
C
${
tdiffstr
}
"
local
cols
=
$((
COLUMNS
-
${#
tdiffstr
}
-
1
))
echo
-e
"
\0
33[1A
\0
33[
${
cols
}
C
${
tdiffstr
}
"
fi
fi
fi
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment