Skip to content

feat: Implement dynamic left and right prompt prefix options#150

Merged
reobin merged 4 commits intomainfrom
feat/dynamic-prompt-prefix
Oct 19, 2022
Merged

feat: Implement dynamic left and right prompt prefix options#150
reobin merged 4 commits intomainfrom
feat/dynamic-prompt-prefix

Conversation

@reobin
Copy link
Owner

@reobin reobin commented Oct 10, 2022

Closes #148

4 "new" options were implemented:

  • TYPEWRITTEN_LEFT_PROMPT_PREFIX (existed before)
  • TYPEWRITTEN_LEFT_PROMPT_PREFIX_FUNCTION
  • TYPEWRITTEN_RIGHT_PROMPT_PREFIX
  • TYPEWRITTEN_RIGHT_PROMPT_PREFIX_FUNCTION

The _FUNCTION variants are used to enable the use of live evaluated functions as prefixes.

Example of use in .zshrc to display kube context:

display_kube_context() {
  tw_kube_context="$(kubectl config current-context 2> /dev/null)"

  if [[ $tw_kube_context != "" ]]; then
    echo "($(basename $tw_kube_context))"
  fi
}

export TYPEWRITTEN_LEFT_PROMPT_PREFIX_FUNCTION=display_kube_context

@reobin
Copy link
Owner Author

reobin commented Oct 10, 2022

Hello @KEDLogic ! If you have the chance to review this PR, it would be greatly appreciated. Especially the example snippet for kube context.

Copy link

@KEDLogic KEDLogic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!
It just needs a small edit to the kubecontext snippet as noted.

@reobin reobin requested a review from KEDLogic October 12, 2022 18:27
@reobin reobin merged commit 8885d84 into main Oct 19, 2022
@reobin reobin deleted the feat/dynamic-prompt-prefix branch October 19, 2022 13:36
@reobin
Copy link
Owner Author

reobin commented Oct 19, 2022

@all-contributors please add @KEDLogic for documentation and ideas

@allcontributors
Copy link
Contributor

@reobin

I've put up a pull request to add @KEDLogic! 🎉

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

Successfully merging this pull request may close these issues.

Timestamp on prompt

2 participants