mirror of
https://github.com/ChesterYue/ohmyzsh-theme-passion.git
synced 2026-07-21 20:11:03 +00:00
[A] system compatibility
This commit is contained in:
parent
697f0e1a02
commit
a24c93e9e0
1 changed files with 25 additions and 3 deletions
|
|
@ -77,7 +77,7 @@ output_command_execute_after() {
|
|||
time="${color_time}${time}${color_reset}";
|
||||
|
||||
# cost
|
||||
local time_end="$(gdate +%s.%3N)";
|
||||
local time_end="$(current_time_millis)";
|
||||
local cost=$(bc -l <<<"${time_end}-${COMMAND_TIME_BEIGIN}");
|
||||
COMMAND_TIME_BEIGIN="-20200325"
|
||||
local length_cost=${#cost};
|
||||
|
|
@ -97,7 +97,29 @@ output_command_execute_after() {
|
|||
# command execute before
|
||||
# REF: http://zsh.sourceforge.net/Doc/Release/Functions.html
|
||||
preexec() {
|
||||
COMMAND_TIME_BEIGIN="$(gdate +%s.%3N)";
|
||||
COMMAND_TIME_BEIGIN="$(current_time_millis)";
|
||||
}
|
||||
|
||||
current_time_millis() {
|
||||
local time_millis;
|
||||
if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
||||
# Linux
|
||||
time_millis="$(date +%s.%3N)";
|
||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# macOS
|
||||
time_millis="$(gdate +%s.%3N)";
|
||||
elif [[ "$OSTYPE" == "cygwin" ]]; then
|
||||
# POSIX compatibility layer and Linux environment emulation for Windows
|
||||
elif [[ "$OSTYPE" == "msys" ]]; then
|
||||
# Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
|
||||
elif [[ "$OSTYPE" == "win32" ]]; then
|
||||
# I'm not sure this can happen.
|
||||
elif [[ "$OSTYPE" == "freebsd"* ]]; then
|
||||
# ...
|
||||
else
|
||||
# Unknown.
|
||||
fi
|
||||
echo $time_millis;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -144,4 +166,4 @@ TRAPALRM() {
|
|||
|
||||
|
||||
# prompt
|
||||
PROMPT='$(real_time) $(directory) $(git_status)$(command_status) ';
|
||||
PROMPT='$(real_time) $(directory) $(git_status)$(command_status) ';
|
||||
Loading…
Add table
Reference in a new issue