Skip to content

Commit

Permalink
'install-dotfiles' script can now handle multiple env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
vraravam committed Dec 3, 2024
1 parent 390dd3a commit 6300bc0
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 3 deletions.
Empty file removed TODO.txt
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Thumbs.db
/*Profile/**/Photos
/*Profile/**/QuotaManager
/*Profile/**/Reporting\ and\ NEL
/*Profile/**/RunningChromeVersion
/*Profile/**/safebrowsing-failedupdate
/*Profile/**/Service\ Worker/**
/*Profile/**/Session\ Storage
Expand Down
7 changes: 4 additions & 3 deletions scripts/install-dotfiles.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ def override_into_home_folder(file, dotfiles_dir_length)
# git doesn't handle symlinks for its core configuration files, so files with 'custom.git' in their name have to be handled separately
relative_file_name = file[dotfiles_dir_length..-1].gsub('custom.git', '.git')

# rename the profiles folder path to pick up the current user's name dynamically
relative_file_name.gsub!('/template/', "/#{`whoami`.chomp}/") if relative_file_name.match?(/\/template\//)
# process folder names having '--' in their name (strings within two pairs of '--' will refer to env variables)
relative_file_name = relative_file_name.split('--').map { |entry| ENV.has_key?(entry) ? ENV[entry] : entry }.join if relative_file_name.include?('--')

target_file_name = File.join(ENV['HOME'], relative_file_name)
# since some env var might already contain the full path from the root...
target_file_name = relative_file_name.start_with?(ENV['HOME']) ? relative_file_name : File.join(ENV['HOME'], relative_file_name)

puts "Processing #{file.yellow} --> #{target_file_name.yellow}"

Expand Down

0 comments on commit 6300bc0

Please sign in to comment.