serhii.net

In the middle of the desert you can say anything you want

27 Nov 2020

Day 697

Zsh prompt change based on dev/prod

The script that sets dev/prod sets a variable to 1 if using dev. Based on that variable I get (or not) a red (B) in my zsh prompt.

Did these changes to the theme clean2.zsh-theme:

PROMPT='%{$fg[green]%}(%*/%!)$ZSH_USING_DEV%{$fg[$NCOLOR]%}%B%b%{$reset_color%}%{$fg[blue]%}%B%5c/%b%{$reset_color%} $(git_prompt_info)%(!.#.$) '

ZSH_USING_DEV=""
if [ "$USING_DEV" = "1" ] 
	then
		ZSH_USING_DEV="%{$fg_bold[red]%}[B]%{$fg[$NCOLOR]%}"
	fi

and in ~/.zsrhc

alias uc='. ~/s/setenv.sh p'
alias ud='. ~/s/setenv.sh d'

zsh prompt export variables from a script

Using the usual ./ way doesn’t work!

Note the . ~/s.. in the script above. Running it as ~/what.sh will create a new shell, export the new values there, and close it. Starting with a . will make it run the script without starting a new shell. 1

Nel mezzo del deserto posso dire tutto quello che voglio.