.dotfiles-dir -> .dotfiles-config

This commit is contained in:
2025-09-18 01:39:35 -07:00
parent ca2f0e18b4
commit 481bf28d44
6 changed files with 40 additions and 17 deletions
+3 -3
View File
@@ -14,9 +14,9 @@ dependencies=(
)
# Load dotfiles directory into DOTFILES_DIR
# Dotfiles directory should be in environment or ~/.dotfiles-dir
if [ -f "$HOME/.dotfiles-dir" ]; then
source "$HOME/.dotfiles-dir"
# Dotfiles directory should be in environment or ~/.dotfiles-config
if [ -f "$HOME/.dotfiles-config" ]; then
source "$HOME/.dotfiles-config"
fi
# PATHs
+1 -1
View File
@@ -6,7 +6,7 @@ Type=simple
User=brad
Environment=DISPLAY=:0
ExecStartPre=/bin/sleep 3
# TODO: The file might not be here if ~/.dotfiles-dir set to somewhere else
# TODO: The file might not be here if ~/.dotfiles-config set to somewhere else
ExecStart=/home/brad/dotfiles/bin/start-wallpaper.sh
[Install]
+2 -2
View File
@@ -149,8 +149,8 @@ if [ -n "$NO_GIT_CHECK" ] && [ ! "$NO_GIT_CHECK" -eq 1 ]; then
elif [[ $dotfiles_version = 4 ]]; then
echo "Dotfiles repository at $DOTFILES_DIR has diverged from origin"
elif [[ $dotfiles_version = 5 ]]; then
echo "Dotfiles repository not set in $HOME/.dotfiles-dir"
echo "Please run ./install.sh in dotfiles repository and exit to create ~/.dotfiles-dir"
echo "Dotfiles repository not set in $HOME/.dotfiles-config"
echo "Please run ./install.sh in dotfiles repository and exit to create ~/.dotfiles-config"
echo "The following will not work until this is set:"
echo " - oh-my-zsh will not be started"
echo " - gruvbox color palette will not be loaded"
+4 -4
View File
@@ -5,11 +5,11 @@ source "$HOME/.profile"
if [ -f "$HOME/.profile.local" ]; then
source "$HOME/.profile.local"
fi
if [ -f "$HOME/.dotfiles-dir" ]; then
source "$HOME/.dotfiles-dir"
if [ -f "$HOME/.dotfiles-config" ]; then
source "$HOME/.dotfiles-config"
else
echo "Dotfiles repository not set in $HOME/.dotfiles-dir"
echo "Please run ./install.sh in dotfiles repository and exit to create ~/.dotfiles-dir"
echo "Dotfiles repository not set in $HOME/.dotfiles-config"
echo "Please run ./install.sh in dotfiles repository and exit to create ~/.dotfiles-config"
exit 1
fi
if [ -z "$DOTFILES_LOCAL_REPOSITORY" ]; then
+18
View File
@@ -24,3 +24,21 @@ function user_service_enabled {
return "$return_"
}
function update_dotfiles_config {
if [ "$#" != 2 ]; then
echo "Usage: update_dotfiles_config ENV_VARIABLE VALUE"
exit 1
fi
local var="$1"
local val="$2"
if [ ! -f "$HOME/.dotfiles-config" ]; then
touch "$HOME/.dotfiles-config"
fi
if [ $(cat "$HOME/.dotfiles-config" | grep -Eq "^export $1=.*$") ]; then
sed -i "s/$1=.*$/$1=$2/" "$HOME/.dotfiles-config"
else
echo "export $1=$2" >> "$HOME/.dotfiles-config"
fi
}
+12 -7
View File
@@ -70,20 +70,26 @@
# Then go into iTerm2 settings and set Source Code Pro for Powerline as the font
dir="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" # dotfiles repository directory
# TODO: Migrate this to an environment variable in .profile.local
if [ ! -f "$HOME/.dotfiles-dir" ]; then
source "$DOTFILES_DIR"/functions.sh
if [ -f "$HOME/.dotfiles-dir" ]; then
# Migrate legacy config
echo "Migrating .dotfiles-dir to .dotfiles-config"
mv "$HOME/.dotfiles-dir" "$HOME/.dotfiles-config"
fi
if [ ! -f "$HOME/.dotfiles-config" ]; then
if [ ! -f "$dir/install.sh" ] || [ ! -f "$dir/dotfiles-local.sh" ]; then
echo "Please run this script initially from within the dotfiles directory"
exit 1
fi
echo "Writing 'export DOTFILES_DIR=$dir' to $HOME/.dotfiles-dir"
echo "export DOTFILES_DIR=$dir" > "$HOME/.dotfiles-dir"
echo "Writing 'export DOTFILES_DIR=$dir' to $HOME/.dotfiles-config"
update_dotfiles_config "DOTFILES_DIR" "$dir"
# echo "export DOTFILES_DIR=$dir" > "$HOME/.dotfiles-config"
echo ""
else
echo "Loading existing $HOME/.dotfiles-dir"
echo "Loading existing $HOME/.dotfiles-config"
echo ""
fi
source "$HOME/.dotfiles-dir"
source "$HOME/.dotfiles-config"
unset dir
config_dir="$DOTFILES_DIR"/config
packages_dir="$DOTFILES_DIR"/packages
@@ -93,7 +99,6 @@ pacman_args="--noconfirm --needed"
restart_needed=0
interactive=0
source "$DOTFILES_DIR"/functions.sh
if [ ! -L $DOTFILES_DIR/bin/dotfiles-install ]; then
echo "Adding this script to PATH. 'dotfiles-install' to run in the future"
ln -s "$DOTFILES_DIR/install.sh" "$DOTFILES_DIR/bin/dotfiles-install"