migrate existing .bashrc_local and .bashrc_paths into repo on setup
This commit is contained in:
parent
a2ffa6afb5
commit
d964af18cb
24
setup_env.sh
24
setup_env.sh
@ -52,15 +52,35 @@ create_symlink() {
|
||||
ln -s "$target" "$link_name"
|
||||
}
|
||||
|
||||
# Like create_symlink, but if the dotfiles/ target doesn't exist yet and the
|
||||
# home file is a real file (not a symlink), migrate it into the repo first.
|
||||
# Used for gitignored files (.bashrc_local, .bashrc_paths) so existing machine
|
||||
# config is preserved rather than buried in a .backup file.
|
||||
migrate_and_link() {
|
||||
local target=$1
|
||||
local link_name=$2
|
||||
|
||||
if [[ ! -e "$target" && -f "$link_name" && ! -L "$link_name" ]]; then
|
||||
echo "Migrating existing $link_name -> $target"
|
||||
cp "$link_name" "$target"
|
||||
fi
|
||||
|
||||
create_symlink "$target" "$link_name"
|
||||
}
|
||||
|
||||
# Deploy configuration files as symlinks
|
||||
deploy_configs() {
|
||||
echo "Deploying configuration files as symlinks..."
|
||||
CONFIG_DIR="$(pwd)/dotfiles" # Use the local 'dotfiles' directory in the repo
|
||||
CONFIG_DIR="$(pwd)/dotfiles"
|
||||
|
||||
for config in .bashrc .bashrc_local .bashrc_paths .vimrc .gitconfig .pspgconf .psqlrc .tmux.conf ; do
|
||||
for config in .bashrc .vimrc .gitconfig .pspgconf .psqlrc .tmux.conf ; do
|
||||
create_symlink "$CONFIG_DIR/$config" ~/$config
|
||||
done
|
||||
|
||||
for config in .bashrc_local .bashrc_paths ; do
|
||||
migrate_and_link "$CONFIG_DIR/$config" ~/$config
|
||||
done
|
||||
|
||||
echo "Sourcing .bashrc..."
|
||||
source ~/.bashrc
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user