replace remove_directory
with trash
- `trash` moves files and directories to the trash directory instead of permanently deleting them
This commit is contained in:
parent
826209a81f
commit
061c34b581
3 changed files with 9 additions and 6 deletions
|
@ -21,6 +21,7 @@ def initialize():
|
||||||
Initialize before running any code.
|
Initialize before running any code.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
install_via_pacman("trash-cli")
|
||||||
install_via_pacman("flatpak")
|
install_via_pacman("flatpak")
|
||||||
install_via_pacman("pip")
|
install_via_pacman("pip")
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from src.util import paru_install, copy_file, remove_directory
|
from src.util import paru_install, copy_file, trash
|
||||||
from src.constants import content_dir, home_dir
|
from src.constants import content_dir, home_dir
|
||||||
from src import log
|
from src import log
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ def setup():
|
||||||
|
|
||||||
log.log("Installing powerlevel10k theme")
|
log.log("Installing powerlevel10k theme")
|
||||||
p10k_path = f"{home_dir}/.oh-my-zsh/custom/themes/powerlevel10k"
|
p10k_path = f"{home_dir}/.oh-my-zsh/custom/themes/powerlevel10k"
|
||||||
remove_directory(p10k_path)
|
trash(p10k_path)
|
||||||
system(
|
system(
|
||||||
f"git clone --depth=1 https://github.com/romkatv/powerlevel10k.git {p10k_path}"
|
f"git clone --depth=1 https://github.com/romkatv/powerlevel10k.git {p10k_path}"
|
||||||
)
|
)
|
||||||
|
@ -29,7 +29,7 @@ def setup():
|
||||||
zsh_syntax_highlighting_path = (
|
zsh_syntax_highlighting_path = (
|
||||||
f"{home_dir}/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting"
|
f"{home_dir}/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting"
|
||||||
)
|
)
|
||||||
remove_directory(zsh_syntax_highlighting_path)
|
trash(zsh_syntax_highlighting_path)
|
||||||
system(
|
system(
|
||||||
f"git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting.git {zsh_syntax_highlighting_path}"
|
f"git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting.git {zsh_syntax_highlighting_path}"
|
||||||
)
|
)
|
||||||
|
|
|
@ -47,11 +47,13 @@ def smart_mkdir(path: str):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def remove_directory(path):
|
def trash(path):
|
||||||
|
"""Moves a file or directory to freedesktop trash."""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
system(f"rm -rf {path}")
|
system(f"trash-put {path}")
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
print(f"Failed to remove directory: {path}")
|
print(f"Failed to remove: {path}")
|
||||||
raise err
|
raise err
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue