Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to display date/time/datetime/timestamp in pre-prompt line #667

Open
simonepri opened this issue Dec 16, 2023 · 0 comments
Open

Comments

@simonepri
Copy link

Desired result

image

Workaround

Add the following to your .zshrc (or equivalent for your shell)

# prepend datetime to pure prompt
eval "original_$(declare -f prompt_pure_preprompt_render)"
prompt_pure_preprompt_render() {
  local prompt_pure_date_color='239'
  local prompt_pure_date_format="[%y/%m/%d %H:%M:%S]"
  zstyle -t :prompt:pure:date color
  if [ $? -eq 1 ]; then
    zstyle -s :prompt:pure:date color prompt_pure_date_color
  fi
  zstyle -t :prompt:pure:date format
  if [ $? -eq 1 ]; then
    zstyle -s :prompt:pure:date format prompt_pure_date_format
  fi
  local prompt_pure_date=$(date "+$prompt_pure_date_format")
  original_prompt_pure_preprompt_render
  PROMPT="%F{$prompt_pure_date_color}${prompt_pure_date}%f $PROMPT"
}

Use zstyle :prompt:pure:date color XXX and zstyle :prompt:pure:date format XXX to customize the format and colour of the date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant