removed cost function
This commit is contained in:
@@ -120,51 +120,51 @@ output_command_execute_after() {
|
|||||||
local color_time="$fg_no_bold[cyan]";
|
local color_time="$fg_no_bold[cyan]";
|
||||||
time="${color_time}${time}${color_reset}";
|
time="${color_time}${time}${color_reset}";
|
||||||
|
|
||||||
# cost
|
# # cost
|
||||||
local time_end="$(current_time_millis)";
|
# local time_end="$(current_time_millis)";
|
||||||
local cost=$(bc -l <<<"${time_end}-${COMMAND_TIME_BEGIN}");
|
# local cost=$(bc -l <<<"${time_end}-${COMMAND_TIME_BEGIN}");
|
||||||
COMMAND_TIME_BEGIN="-20200325"
|
# COMMAND_TIME_BEGIN="-20200325"
|
||||||
local length_cost=${#cost};
|
# local length_cost=${#cost};
|
||||||
if [ "$length_cost" = "4" ];
|
# if [ "$length_cost" = "4" ];
|
||||||
then
|
# then
|
||||||
cost="0${cost}"
|
# cost="0${cost}"
|
||||||
fi
|
# fi
|
||||||
cost="[cost ${cost}s]"
|
# cost="[cost ${cost}s]"
|
||||||
local color_cost="$fg_no_bold[cyan]";
|
# local color_cost="$fg_no_bold[cyan]";
|
||||||
cost="${color_cost}${cost}${color_reset}";
|
# cost="${color_cost}${cost}${color_reset}";
|
||||||
|
|
||||||
echo -e "${time} ${cost} ${cmd}";
|
# echo -e "${time} ${cost} ${cmd}";
|
||||||
echo -e "";
|
# echo -e "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# command execute before
|
# command execute before
|
||||||
# REF: http://zsh.sourceforge.net/Doc/Release/Functions.html
|
# REF: http://zsh.sourceforge.net/Doc/Release/Functions.html
|
||||||
preexec() { # cspell:disable-line
|
# preexec() { # cspell:disable-line
|
||||||
COMMAND_TIME_BEGIN="$(current_time_millis)";
|
# COMMAND_TIME_BEGIN="$(current_time_millis)";
|
||||||
}
|
# }
|
||||||
|
|
||||||
current_time_millis() {
|
# current_time_millis() {
|
||||||
local time_millis;
|
# local time_millis;
|
||||||
if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
# if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
||||||
# Linux
|
# # Linux
|
||||||
time_millis="$(date +%s.%3N)";
|
# time_millis="$(date +%s.%3N)";
|
||||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
# elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
# macOS
|
# # macOS
|
||||||
time_millis="$(gdate +%s.%3N)";
|
# time_millis="$(gdate +%s.%3N)";
|
||||||
elif [[ "$OSTYPE" == "cygwin" ]]; then
|
# elif [[ "$OSTYPE" == "cygwin" ]]; then
|
||||||
# POSIX compatibility layer and Linux environment emulation for Windows
|
# # POSIX compatibility layer and Linux environment emulation for Windows
|
||||||
elif [[ "$OSTYPE" == "msys" ]]; then
|
# elif [[ "$OSTYPE" == "msys" ]]; then
|
||||||
# Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
|
# # Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
|
||||||
elif [[ "$OSTYPE" == "win32" ]]; then
|
# elif [[ "$OSTYPE" == "win32" ]]; then
|
||||||
# I'm not sure this can happen.
|
# # I'm not sure this can happen.
|
||||||
elif [[ "$OSTYPE" == "freebsd"* ]]; then
|
# elif [[ "$OSTYPE" == "freebsd"* ]]; then
|
||||||
# ...
|
# # ...
|
||||||
else
|
# else
|
||||||
# Unknown.
|
# # Unknown.
|
||||||
fi
|
# fi
|
||||||
echo $time_millis;
|
# echo $time_millis;
|
||||||
}
|
# }
|
||||||
|
|
||||||
|
|
||||||
# command execute after
|
# command execute after
|
||||||
|
|||||||
Reference in New Issue
Block a user