Show perl version in prompt


For my perl jobs i always use the grade tool perlbrew. Doing multiple jobs in multiple perl environment is need so switch the perl envonriment contantly. To see which perl version i am using currently i made s small extension for the zsh shell.

I am using the theme powerlevel9k and added the following lines to my .zshrc:

1POWERLEVEL9K_CUSTOM_PERL_VERSION="perl_version_print"
2POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir rbenv vcs)
3POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status history time custom_perl_version)
4
5perl_version_print () {
6    echo $(env perl -e 'print $^V')
7}

The first three lines set environemtn variables specific for the powerlevel96 theme. In the first line i defined a new keyword (perl_version_print) and use it in line 3 to be displayed on the right side in the shell. The last lines define the function that is called to determin the current perl version.

Here is screenshot what it will look like:

perl version