#!/bin/bash
NVS_HOME="${NVS_HOME:-'$HOME/.nvs'}";
NVS_PATH="${NVS_PATH}";

bashProfile="/etc/bash.bashrc";

for profile in "$bashProfile" "/etc/fish/conf.d/nvs.fish" "/etc/zsh/zprofile"
do
    if ! grep "\bNVS_HOME\b" "$profile"
    then
        {
            echo "export NVS_HOME=\"$NVS_HOME\"";
            echo 'source "'"$NVS_PATH"'/nvs.sh"';
        } | sudo tee -a "$profile";
    fi;
done;

source "$bashProfile";
nvs add latest;
nvs link latest;