fix bug and add linux-custom-rc.zsh

This commit is contained in:
A.C.Sukazyo Eyre 2024-04-06 19:14:58 +08:00
parent 961dfe65ef
commit 9900ce304b
Signed by: Eyre_S
GPG Key ID: C17CE40291207874
2 changed files with 57 additions and 36 deletions

17
sync.py
View File

@ -1,4 +1,3 @@
from turtle import back
from typing import Callable, Iterable, TypeVar
from enum import Enum
from math import nan
@ -77,11 +76,13 @@ class BackupItem:
def execute_sync (backupItem: BackupItem) -> None:
print(f">>> executing backup for {backupItem.name}")
all_files_tmp: list[str] = []
exec_gallery: list[Callable] = []
### for file mode
if (path.isfile(backupItem.origin_dir)) or (path.isfile(backupItem.backup_dir)):
compare_file(backupItem, None)
exec_gallery.append(compare_file(backupItem, None))
### for dir mode
else:
all_files_tmp: list[str] = []
def walk_dir (walking_dir: str):
for root, dirs, files in os.walk(walking_dir):
common_root: str = path.commonpath([root, walking_dir])
@ -97,9 +98,11 @@ def execute_sync (backupItem: BackupItem) -> None:
walk_dir(backupItem.origin_dir)
walk_dir(backupItem.backup_dir)
all_files: list[str] = sorted_paths(set(all_files_tmp))
exec_gallery: list[Callable] = []
for file in all_files:
exec_gallery.append(compare_file(backupItem, file))
if exec_gallery.__len__() == 0:
print("no files to sync ~")
return
while True:
print("! sync those files now? [y/n] ", end="")
_in = input()
@ -109,8 +112,6 @@ def execute_sync (backupItem: BackupItem) -> None:
return
elif _in == 'n':
return
else:
print("! sync those files now? [y/n] ", end="")
def compare_file (rootBackItem: BackupItem, relative_file_path: str|None) -> Callable:
class NewerStatus (Enum):
@ -164,9 +165,6 @@ def compare_file (rootBackItem: BackupItem, relative_file_path: str|None) -> Cal
# print(f"((origin_item: {origin_item.path}))")
def wait_for_if_remove (onSync = Callable, onRemove = Callable) -> Callable[[str], Callable|None]:
def implementation (_in: str) -> Callable|None:
while True:
_in = input()
match _in:
case "s":
return onSync
@ -250,6 +248,7 @@ else:
sys_type: SysType = SysType.WINDOWS
print(f"dot-config: your dot-config path is {backup_root}")
print(f"dot-config: your system type is {sys_type}")
print(f"dot-config: dry run mode is {dry_run}")
print(f"Is all the information correct? [y/n] ", end="")
while True:
_in = input()

22
zsh/linux.custom_rc.zsh Normal file
View File

@ -0,0 +1,22 @@
#!/bin/zsh
#=== bat (cat)
alias cat='bat'
#=== lsd
alias cols='lsd'
alias crls='cols'
alias ccls='crls -g'
alias cl='ccls -lA'
alias cll='ccls -l'
alias cla='ccls -la'
alias lc='ccls'
alias ls='lc'
alias l='cl'
alias ll='cll'
alias la='cla'
alias lgg='ccls --tree'
#=== zoxide (cd)
# zoxide must init after compinit is called
eval "$(zoxide init zsh)"
alias cd='z'