DEV Community

Discussion on: My Terminal Setup

Collapse
 
romkatv profile image
Roman Perepelitsa • Edited

Function prompt_customIcon is slower than it could be (due to forking) and isn't quite correct. Here's a fixed version:

function prompt_customIcon() {
  local -i currenttime=${(%):-%D{%H%M}}
  if (( currenttime > 1619 || currenttime < 421 )); then
    ...
  else
    ...
  fi
}

It's also a very good idea to prefix all your custom prompt segments with my_ to avoid clashes with future versions of powerlevel10k.

function prompt_my_icon() {
  ...
}
Collapse
 
hipstersmoothie profile image
802.11 Savage

Thanks for the tip! What do you mean by forking?

Collapse
 
romkatv profile image
Roman Perepelitsa

It calls an external command (date), which is implemented as fork + exec. Both of these calls are very expensive and slow.