There's a couple of ways you could do this. You should look into the precmd
and preexec
functions. They're in the hook functions
section of zshmisc
(which you can read online or using man zshmisc
.
A simple solution would be to read this unix.stackexchange.com question, which says to put this in your ~/.zshrc
file:
setopt prompt_subst
PROMPT='$TOKEN'
This will do what you want:
┌─(simont@charmander:s000)─────────────────────────────────────▸▸▸▸▸▸▸▸▸▸─(~ )─┐
└─(12:44)── export GREETING="foo" ──(Wed,Dec12)─┘
foo ┌─(simont@charmander:s000)─────────────────────────────────▸▸▸▸▸▸▸▸▸▸─(~ )─┐
└─(12:44)── export GREETING="bar" ──(Wed,Dec12)─┘
bar ┌─(simont@charmander:s000)─────────────────────────────────▸▸▸▸▸▸▸▸▸▸─(~ )─┐
└─(12:44)──
(This messes up my prompt a little, but you can see the foo
and bar
displaying nicely as they should, updating when $GREETING
is changed. In your case, use $TOKEN
).
My prompt heavily borrows from Phil!'s ZSH Prompt, which I found very useful when learning to customise mine.