Skip to content

Commit

Permalink
rewrite the dotfiles setup function
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarmos-san committed Aug 20, 2023
1 parent b4a7b4e commit bed5d78
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions setup-rewrite
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,36 @@ def install_zsh_plugins(dry_run: bool = DRY_RUN) -> None:
print("Simulating ZSH plugins installation...")


def setup_dotfiles() -> None:
def setup_dotfiles(dry_run: bool = DRY_RUN) -> None:
"""Set up dotfiles for the system."""
pass
dotfiles_dir = Path(f"{Path.home()}/.dotfiles")

if not dry_run:
# INFO: Create the "~/.dotfiles" directory if it doesn't already exists
if not dotfiles_dir.exists() and not dotfiles_dir.is_dir():
Path.mkdir(dotfiles_dir)

# INFO: Attempt to download the dotfiles from the remote repository on GitHub
try:
subprocess.run(
["git", "clone", "[email protected]:Jarmos-san/dotfiles", dotfiles_dir]
)
except subprocess.CalledProcessError as error:
print(error)

# INFO: Check if the contents of the ".dotfiles" repository are already
# symlinked, if yes then attempt to remove the links
for content in Path.iterdir(dotfiles_dir / "dotfiles"):
if content.is_symlink():
content.unlink(missing_ok=True)

# INFO: Create symlinks of the contents from "~/.dotfiles/dotfiles" directory
for content in Path.iterdir(dotfiles_dir / "dotfiles"):
content.symlink_to(
target=f"{Path.home()}/{content}", target_is_directory=True
)
else:
print("Simulating dotfiles setup...")


def install_docker() -> None:
Expand Down

0 comments on commit bed5d78

Please sign in to comment.