From afa1d96c2e21f114ef6e6244dea8989b540cff1b Mon Sep 17 00:00:00 2001 From: hesam-init Date: Thu, 21 Mar 2024 20:59:24 +0330 Subject: [PATCH] refactor: stow shell file --- configs/{sh => shell}/.bashrc | 0 configs/{sh => shell}/.shell/dns-changer.sh | 0 configs/{sh => shell}/.steam-os/main.sh | 0 configs/{sh => shell}/.zsh/aliases/dir.zsh | 0 configs/{sh => shell}/.zsh/aliases/git.zsh | 0 configs/{sh => shell}/.zsh/aliases/main.zsh | 0 configs/{sh => shell}/.zsh/functions/main.zsh | 0 configs/{sh => shell}/.zsh/os/debian.zsh | 0 configs/{sh => shell}/.zsh/os/void.zsh | 0 configs/{sh => shell}/.zshenv | 0 configs/{sh => shell}/.zshlogin | 0 configs/{sh => shell}/.zshrc | 0 stow.sh | 43 ++++++++++++------- 13 files changed, 27 insertions(+), 16 deletions(-) rename configs/{sh => shell}/.bashrc (100%) rename configs/{sh => shell}/.shell/dns-changer.sh (100%) rename configs/{sh => shell}/.steam-os/main.sh (100%) rename configs/{sh => shell}/.zsh/aliases/dir.zsh (100%) rename configs/{sh => shell}/.zsh/aliases/git.zsh (100%) rename configs/{sh => shell}/.zsh/aliases/main.zsh (100%) rename configs/{sh => shell}/.zsh/functions/main.zsh (100%) rename configs/{sh => shell}/.zsh/os/debian.zsh (100%) rename configs/{sh => shell}/.zsh/os/void.zsh (100%) rename configs/{sh => shell}/.zshenv (100%) rename configs/{sh => shell}/.zshlogin (100%) rename configs/{sh => shell}/.zshrc (100%) diff --git a/configs/sh/.bashrc b/configs/shell/.bashrc similarity index 100% rename from configs/sh/.bashrc rename to configs/shell/.bashrc diff --git a/configs/sh/.shell/dns-changer.sh b/configs/shell/.shell/dns-changer.sh similarity index 100% rename from configs/sh/.shell/dns-changer.sh rename to configs/shell/.shell/dns-changer.sh diff --git a/configs/sh/.steam-os/main.sh b/configs/shell/.steam-os/main.sh similarity index 100% rename from configs/sh/.steam-os/main.sh rename to configs/shell/.steam-os/main.sh diff --git a/configs/sh/.zsh/aliases/dir.zsh b/configs/shell/.zsh/aliases/dir.zsh similarity index 100% rename from configs/sh/.zsh/aliases/dir.zsh rename to configs/shell/.zsh/aliases/dir.zsh diff --git a/configs/sh/.zsh/aliases/git.zsh b/configs/shell/.zsh/aliases/git.zsh similarity index 100% rename from configs/sh/.zsh/aliases/git.zsh rename to configs/shell/.zsh/aliases/git.zsh diff --git a/configs/sh/.zsh/aliases/main.zsh b/configs/shell/.zsh/aliases/main.zsh similarity index 100% rename from configs/sh/.zsh/aliases/main.zsh rename to configs/shell/.zsh/aliases/main.zsh diff --git a/configs/sh/.zsh/functions/main.zsh b/configs/shell/.zsh/functions/main.zsh similarity index 100% rename from configs/sh/.zsh/functions/main.zsh rename to configs/shell/.zsh/functions/main.zsh diff --git a/configs/sh/.zsh/os/debian.zsh b/configs/shell/.zsh/os/debian.zsh similarity index 100% rename from configs/sh/.zsh/os/debian.zsh rename to configs/shell/.zsh/os/debian.zsh diff --git a/configs/sh/.zsh/os/void.zsh b/configs/shell/.zsh/os/void.zsh similarity index 100% rename from configs/sh/.zsh/os/void.zsh rename to configs/shell/.zsh/os/void.zsh diff --git a/configs/sh/.zshenv b/configs/shell/.zshenv similarity index 100% rename from configs/sh/.zshenv rename to configs/shell/.zshenv diff --git a/configs/sh/.zshlogin b/configs/shell/.zshlogin similarity index 100% rename from configs/sh/.zshlogin rename to configs/shell/.zshlogin diff --git a/configs/sh/.zshrc b/configs/shell/.zshrc similarity index 100% rename from configs/sh/.zshrc rename to configs/shell/.zshrc diff --git a/stow.sh b/stow.sh index d55e378..6588198 100755 --- a/stow.sh +++ b/stow.sh @@ -1,7 +1,10 @@ #!/bin/bash configs_dir="$(pwd)/configs" -shortcuts_dir="$(pwd)/configs/shortcuts" +dotfiles_dir="$configs_dir/dotfiles" +shell_dir="$configs_dir/shell" +shortcuts_dir="$configs_dir/shortcuts" +hyprland_dir="$configs_dir/hyprland" display_help() { echo "Usage: [-s | -u] [-h]" @@ -50,14 +53,14 @@ unstow_shortcuts() { } stow_dotfiles() { - create_symlinks $configs_dir/dotfiles ~/.config - create_symlinks $configs_dir/sh ~/ + create_symlinks $dotfiles_dir ~/.config + create_symlinks $shell_dir ~/ echo "Dotfiles stowed successfully!" } unstow_dotfiles() { - for folder in $configs_dir/dotfiles/*; do + for folder in $dotfiles_dir/*; do local folder_name=$(basename $folder) local target_folder=~/.config/$folder_name @@ -69,7 +72,7 @@ unstow_dotfiles() { fi done - for config in $configs_dir/sh/.*; do + for config in $shell_dir/.*; do if [ -f $config ]; then local file_name=$(basename $config) local target_file=~/$file_name @@ -96,13 +99,13 @@ unstow_dotfiles() { } stow_hyprland() { - create_symlinks $configs_dir/hyprland ~/.config + create_symlinks $hyprland_dir ~/.config echo "Hyprland stowed successfully!" } unstow_hyprland() { - for config in $configs_dir/hyprland/*; do + for config in $hyprland_dir/*; do config_name=$(basename $config) target_config=~/.config/$config_name @@ -115,20 +118,28 @@ unstow_hyprland() { done } +stow() { + create_target_dir + stow_dotfiles + stow_shortcuts + stow_hyprland +} + +unstow() { + unstow_dotfiles + unstow_shortcuts + unstow_hyprland + + echo "All configs ustowed successfully !" +} + while getopts ":suh" opt; do case $opt in s) - create_target_dir - stow_dotfiles - stow_shortcuts - stow_hyprland + stow ;; u) - unstow_dotfiles - unstow_shortcuts - unstow_hyprland - - echo "All configs stowed successfully !" + unstow ;; *) display_help