dotfm

My dotfile manager
git clone git://src.gearsix.net/dotfm
Log | Files | Refs | Atom | README | LICENSE

commit dd3bf255a6fb297cdcb8345be413b48a3fe97cde
parent 9b873d29cdcf857f16139a73e5ef615987d9dbae
Author: gearsix <gearsix@tuta.io>
Date:   Fri,  8 Oct 2021 12:06:06 +0100

fixed behaviour when installing a file to it's destined location.

If the source file matched the destination path, then any existing file
at the destination path would be overwritten with an empty file. Now it
just registers the destination file and modifies it.

Diffstat:
Msrc/dotfm.py | 19++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/src/dotfm.py b/src/dotfm.py @@ -186,9 +186,9 @@ def install(dotfile): aliases = install_getaliases(known) if not os.path.exists(os.path.dirname(location)): os.makedirs(os.path.dirname(locations), exist_ok=True) - if os.path.lexists(location): - install_oca(dotfile, location) if dotfile != location: + if os.path.lexists(location): + install_oca(dotfile, location) os.system('ln -vs {} {}'.format(dotfile, location)) debug('appending to {} installed...'.format(location)) aliases.insert(0, location) @@ -196,18 +196,17 @@ def install(dotfile): clearduplicates(INSTALLED) info('success - you might need to re-open the terminal to see changes take effect') -def install_getlocation(known_index): +def install_getlocation(known_index, msg='install location?'): default = '' - install = 'install location?' if known_index != -1: default = KNOWN[known_index][0] info('default install location is "{}"'.format(default)) - install = 'install location (enter for default):'.format(default) + msg = 'install location (enter for default):'.format(default) if len(default) > 0 and ARGS.skip == True: return default location = '' while location == '': - location = ask(install) + location = ask(msg) if len(location) == 0 and len(default) > 0: return default elif location.find('~') != -1: @@ -298,13 +297,7 @@ def edit_promptinstall(dotfile): if len(yn) == 0: yn = '-' if yn[0] == 'y': - location = ask('input source filepath: ') - if len(location) == 0: - location = '/home/{}/.{}'.format(USER, dotfile) - log('setting location to "{}"'.format(location)) - f = open(location, 'w') - f.close() - install(location) + install(install_getlocation(-1, msg='input source path:')) return yn[0] # main/list