Merge pull request #692 from androidStern/find_or_create_zshrc_content

Don't append already existing content to .zshrc on rake update
This commit is contained in:
Yan Pritzker 2016-04-28 11:49:27 -05:00
commit 596ebf525a

View File

@ -323,9 +323,12 @@ def install_files(files, method = :symlink)
# Temporary solution until we find a way to allow customization
# This modifies zshrc to load all of yadr's zsh extensions.
# Eventually yadr's zsh extensions should be ported to prezto modules.
source_config_code = "for config_file ($HOME/.yadr/zsh/*.zsh) source $config_file"
if file == 'zshrc'
File.open(target, 'a') do |zshrc|
zshrc.puts('for config_file ($HOME/.yadr/zsh/*.zsh) source $config_file')
File.open(target, 'a+') do |zshrc|
if zshrc.readlines.grep(/#{Regexp.escape(source_config_code)}/).empty?
zshrc.puts(source_config_code)
end
end
end