Persist a Project Environment Variable

ShellBeginner
Practice Now

Introduction

A shell variable disappears when its shell ends unless future shells are told how to recreate it. The preceding guided lab used .zshrc for this purpose.

This challenge asks you to persist one variable only, then observe it from a fresh Zsh session.

Persist the Project Directory

Current Situation

PROJECT_DIR is not configured in /home/labex/.zshrc. A fresh Zsh session therefore does not know the project path.

Scope

  • Configure PROJECT_DIR in /home/labex/.zshrc.
  • Its value must be /home/labex/project.
  • Reload .zshrc in the current shell with source.
  • Save the reloaded value in /home/labex/project/project-variable.txt.

Your Goal

Persist PROJECT_DIR in .zshrc and make its value available after reloading that file.

Acceptance Criteria

  • Reloading .zshrc exports PROJECT_DIR with the value /home/labex/project.
  • After reloading .zshrc, project-variable.txt contains /home/labex/project.

Hints

Where did the guided lab place persistent exports?

It appended an export line to $HOME/.zshrc, then used source to reload the file in the current shell.

Summary

You persisted one exported variable in .zshrc, reloaded the file, and confirmed the resulting value.

✨ Check Solution and Practice