make a global FISH_DURATION variable
danielb2 opened this issue · comments
set -x FISH_DURATION $time_str
Then I use FISH_DURATION in my prompt instead.
I also disabled the echo as part of this timer, I think there should be a switch to do so.
maybe if set fish_command_timer_echo_disabled
is set, it shouldn't echo
or maybe call it FISH_COMMAND_TIMER_STRING
dunno. the idea is the same ;)
Could you elaborate a bit more on what the variable would do?
You can already disable the script by unsetting fish_command_timer_enabled
or setting it to 0. You can also customize the time string with fish_command_timer_time_format
. Do you mean this variable would let you customize the command duration (e.g., '1m2s027')?
Just implemented & merged this feature in #6 and #7. The command duration string is now exported as $CMD_DURATION_STR
(following the naming of the builtin $CMD_DURATION
variable in fish 2.3).
Now, you should be able to achieve the effect in the screenshots by setting fish_command_timer_enabled
to 0
, and using $CMD_DURATION_STR
in the prompt.
Btw - the screenshots are sweet! I like your prompt.
works! Thanks :) only thing now is if I don't want to see the microseconds, it would be nice to format the duration to exclude that :)
Prompt is here:
function fish_prompt
set_color blue
echo -n [
set_color cyan
echo -n (whoami)
set_color 3FF
echo -n @
set_color cyan
echo -n (hostname|cut -d . -f 1)
set_color blue
echo -n ']-('
set_color cyan
echo -n (date +%T)
set_color blue
echo -n ')-('
set_color cyan
echo -n $CMD_DURATION_STR
set_color blue
echo ')'
set_color blue
echo -n [
set_color cyan
echo -n (prompt_pwd)
set_color blue
echo -n ]
set_color green
switch (id -u)
case 0; set prompt_symbol '#'
case '*'; set prompt_symbol '$'
end
echo -n "$prompt_symbol "
set_color normal
end
How come you don't just uset $CMD_DURATION to do your calculations?
You can set fish_command_timer_millis
to 0
to disable showing milliseconds, so it'd only print up to seconds :)
When I wrote the script, my computer at work had a really old version of fish and it didn't have $CMD_DURATION
. But since this script is no longer compatible with pre-2.2 versions anyway, we might as well use $CMD_DURATION
. Will open a new issue for this.