removed cost function

This commit is contained in:
2024-11-25 20:39:47 -08:00
parent 7f06398c0a
commit a4aad67bd3

View File

@@ -120,51 +120,51 @@ output_command_execute_after() {
local color_time="$fg_no_bold[cyan]";
time="${color_time}${time}${color_reset}";
# cost
local time_end="$(current_time_millis)";
local cost=$(bc -l <<<"${time_end}-${COMMAND_TIME_BEGIN}");
COMMAND_TIME_BEGIN="-20200325"
local length_cost=${#cost};
if [ "$length_cost" = "4" ];
then
cost="0${cost}"
fi
cost="[cost ${cost}s]"
local color_cost="$fg_no_bold[cyan]";
cost="${color_cost}${cost}${color_reset}";
# # cost
# local time_end="$(current_time_millis)";
# local cost=$(bc -l <<<"${time_end}-${COMMAND_TIME_BEGIN}");
# COMMAND_TIME_BEGIN="-20200325"
# local length_cost=${#cost};
# if [ "$length_cost" = "4" ];
# then
# cost="0${cost}"
# fi
# cost="[cost ${cost}s]"
# local color_cost="$fg_no_bold[cyan]";
# cost="${color_cost}${cost}${color_reset}";
echo -e "${time} ${cost} ${cmd}";
echo -e "";
# echo -e "${time} ${cost} ${cmd}";
# echo -e "";
}
# command execute before
# REF: http://zsh.sourceforge.net/Doc/Release/Functions.html
preexec() { # cspell:disable-line
COMMAND_TIME_BEGIN="$(current_time_millis)";
}
# preexec() { # cspell:disable-line
# COMMAND_TIME_BEGIN="$(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;
}
# 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;
# }
# command execute after