File tree Expand file tree Collapse file tree 2 files changed +43
-2
lines changed
Expand file tree Collapse file tree 2 files changed +43
-2
lines changed Original file line number Diff line number Diff line change 1+ import os
2+ import shutil
3+ from pathlib import Path
4+
5+ def cleanup ():
6+ # 1. Remove config directory
7+ config_dir = Path .home () / ".config" / "autocmd"
8+ if config_dir .exists ():
9+ print (f"Removing config dir: { config_dir } " )
10+ shutil .rmtree (config_dir )
11+ else :
12+ print ("Config dir not found." )
13+
14+ # 2. Clean .zshrc
15+ zshrc = Path .home () / ".zshrc"
16+ if zshrc .exists ():
17+ lines = zshrc .read_text ().splitlines ()
18+ new_lines = []
19+ skip = False
20+ cleaned = False
21+
22+ for line in lines :
23+ # Identify blocks to remove
24+ if "# autocmd" in line or "alias autocmd-dev=" in line or "autocmd() {" in line :
25+ cleaned = True
26+ continue
27+
28+ # Also remove the logic inside the function if any lines slipped through
29+ # (The previous script was simple filtering, let's keep it simple)
30+
31+ new_lines .append (line )
32+
33+ if cleaned :
34+ print (f"Removing autocmd lines from { zshrc } " )
35+ # Ensure we don't leave weird empty lines, but mostly fine
36+ zshrc .write_text ('\n ' .join (new_lines ) + '\n ' )
37+ else :
38+ print ("No autocmd lines found in .zshrc" )
39+
40+ if __name__ == "__main__" :
41+ cleanup ()
You can’t perform that action at this time.
0 commit comments