fix bug and add linux-custom-rc.zsh
This commit is contained in:
parent
961dfe65ef
commit
9900ce304b
17
sync.py
17
sync.py
@ -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
22
zsh/linux.custom_rc.zsh
Normal 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'
|
Loading…
Reference in New Issue
Block a user