TortoiseGit not showing icon overlays

前端 未结 13 2110
离开以前
离开以前 2020-12-22 17:07

I have been using TortoiseGit for almost a full year now. It has been working very well for me until yesterday, when I encountered a problem. I was deleting a f

13条回答
  •  无人及你
    2020-12-22 17:52

    The problem with the leading spaces is that every time you reboot, Dropbox adds another space to its registries, and will be always one step ahead of you.

    So I've scheduled a python script found on this post (by Christoph Zwerschke) to execute every time the computer boots. You also have to restart the Explorer after that.

    The .bat will look like:

    python iconOverlayFixer.py
    taskkill /f /im explorer.exe 
    start explorer.exe  
    

    And the python script:

    #/usr/bin/python3
    
    import os
    import winreg as reg
    
    # names of all overlay icons that shall be boosted:
    
    boost = """
        Tortoise1Normal
        Tortoise2Modified
        Tortoise3Conflict
        Tortoise4Locked
        Tortoise5ReadOnly
        Tortoise6Deleted
        Tortoise7Added
        Tortoise8Ignored
        Tortoise9Unversioned
    """
    
    boost = set(boost.split())
    
    with reg.OpenKey(reg.HKEY_LOCAL_MACHINE,
            r'SOFTWARE\Microsoft\Windows\CurrentVersion'
            r'\Explorer\ShellIconOverlayIdentifiers') as base:
    
        names = set()
        renames = []
        i = 0
        while True:
            try:
                name = reg.EnumKey(base, i)
            except OSError:
                break
            core = name.strip()
            if core in names:
                print('Delete', repr(core))
                reg.DeleteKey(base, name)
            else:
                names.add(core)
                if core in boost:
                    core = ' ' + core
                if core != name:
                    renames.append((name, core))
            i += 1
    
        if renames:
            for old_name, new_name in renames:
                print('Rename', repr(old_name), 'to', repr(new_name))
                value = reg.QueryValue(base, old_name)
                reg.CreateKey(base, new_name)
                reg.SetValue(base, new_name, reg.REG_SZ, value)
                reg.DeleteKey(base, old_name)
        else:
            print('Nothing to rename')
    

提交回复
热议问题