From c5d54148ed960722b46e1c529f625eac9cd4b6f5 Mon Sep 17 00:00:00 2001 From: Ethan White Date: Thu, 19 Sep 2013 20:33:17 -0400 Subject: [PATCH] Append exports to end of .bash_profile instead of overwriting In the process at an explanation of where the lines came from so that users know they can remove the lines if desired. --- setup/bin/swc-nano-installer.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/setup/bin/swc-nano-installer.py b/setup/bin/swc-nano-installer.py index f27aac1..67dd7e8 100644 --- a/setup/bin/swc-nano-installer.py +++ b/setup/bin/swc-nano-installer.py @@ -48,12 +48,13 @@ def make_bash_profile(home_dir, nano_dir): """ nano_path = make_posix_path(nano_dir) - contents = '\n'.join([ - 'export PATH=$PATH:%s' % nano_path, - 'export EDITOR=nano', - '', - ]) - with open(os.path.join(home_dir, '.bash_profile'), 'w') as f: + contents = '\n'.join(['', + '# Add nano to path and set as default editor', + '# Added by the Software Carpentry nano installer', + 'export PATH=$PATH:%s' % nano_path, + 'export EDITOR=nano', + '']) + with open(os.path.join(home_dir, '.bash_profile'), 'a') as f: f.write(contents) def make_posix_path(windows_path): -- 2.26.2