Don't append already existing content to .zshrc on rake update

This commit is contained in:
Andrew Stern 2016-02-16 18:56:34 -08:00
parent cc4b8043f0
commit f492636e87

View File

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