diff options
| author | Zach DeCook <zach.decook@bettercarpeople.com> | 2024-09-03 11:24:18 -0400 |
|---|---|---|
| committer | Zach DeCook <zach.decook@bettercarpeople.com> | 2024-09-03 11:24:32 -0400 |
| commit | fb86dedd548f283e2df17c0279ec1f7b2c9d3e83 (patch) | |
| tree | 5c1f847c6a874789516e72ac3bd1e0209bef9868 /.local/bin/mfi.py | |
| parent | ed45f26f1c87ac9a27436288b67af66a8abb20ed (diff) | |
| download | dotfiles-fb86dedd548f283e2df17c0279ec1f7b2c9d3e83.tar.gz | |
mfi.py: Fix finding file with partial path
Diffstat (limited to '.local/bin/mfi.py')
| -rwxr-xr-x | .local/bin/mfi.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/.local/bin/mfi.py b/.local/bin/mfi.py index 41bdf7c..b18f620 100755 --- a/.local/bin/mfi.py +++ b/.local/bin/mfi.py @@ -7,8 +7,11 @@ files = [] nums = {} for arg in args: file = arg.split(':')[0] - r = subprocess.run(['find', '.', '-name', file],stdout=subprocess.PIPE) - files += r.stdout.decode().strip().split('\n') + if '/' in file: + r = subprocess.run(['find', '.', '-wholename', '*'+file],stdout=subprocess.PIPE) + else: + r = subprocess.run(['find', '.', '-name', file],stdout=subprocess.PIPE) + files += (r.stdout.decode().strip() or file).split('\n') if ':' in arg: nums[file] = arg.split(':')[1] else: @@ -16,7 +19,8 @@ for arg in args: args = ['micro'] for file in files: - n = nums[file.split('/')[-1]] + if file: + n = nums.get(file, nums.get(file.split('/')[-1], 0)) args.append(file+":"+str(n)) #print(args) |
