Having looked at Setting up environment variables with .sh file and How to permanently set environmental variables I'm still confused as to how to properly set permanent environment variables from a .sh
file (I dip in and out of linux use so I'm certainly a novice).
In my specific case I have a setup-env.sh
:
# Copyright (c) 2015-2019 LunarG, Inc.
# source this file into an existing shell.
VULKAN_SDK="$(dirname "$(readlink -f "${BASH_SOURCE:-$_}" )" )/x86_64"
export VULKAN_SDK
PATH="$VULKAN_SDK/bin:$PATH"
export PATH
LD_LIBRARY_PATH="$VULKAN_SDK/lib:${LD_LIBRARY_PATH:-}"
export LD_LIBRARY_PATH
VK_LAYER_PATH="$VULKAN_SDK/etc/vulkan/explicit_layer.d"
export VK_LAYER_PATH
I could edit /home/jonathan/.bashrc
to contain:
export VK_LAYER_PATH="/home/jonathan/Vulkan/1.2.170.0/x86_64/etc/vulkan/explicit_layer.d"
export VULKAN_SDK="/home/jonathan/Vulkan/1.2.170.0/x86_64"
export LD_LIBRARY_PATH="/home/jonathan/Vulkan/1.2.170.0/x86_64/lib:"
Which is what running . setup-env.sh
sets them to.
But this seems awkward and unnecessarily difficult, is there a better way to run a script and have it set permanent environment variables?
. setup-env.sh
in your ~/.bashrc or ~/.bash_profile or ~/.profilesetup-env.sh
from the Vulkan SDK linux version ( vulkan.lunarg.com/sdk/home#linux)./path/to/dir . setup-env.sh
right?.
is the command, so you would want. /path/to/dir/setup-env.sh
.