From f73d04544ecd08415df34eb788d45e7b4fb56d66 Mon Sep 17 00:00:00 2001 From: statzitz Date: Tue, 27 Aug 2024 11:55:43 +0200 Subject: [PATCH] add fu fr du dr uu and correct a little the config file. --- README.md | 21 ++++++------------- config/files.conf | 30 +++++++++++++-------------- save_config_file | 53 ++++++++++++++++++++++++++++------------------- 3 files changed, 53 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index 2750876..f6dfc30 100644 --- a/README.md +++ b/README.md @@ -4,24 +4,15 @@ Use it to save in ~/Documents/git/dotfiles/dotconfig your config files. ## TODO -### program config file. - -Implement in _INSTRUCTIONS_ -- fu for user file copy -- fr for root file copy (use doas) -- du for user directory copy -- dr for root firectory copy (use doas) - -Rename u by uu, for update user. - -### dotfiles to config - -make as function dotfiles to config - -### config to dotfile +### config to dotfile // save Implement the reverse. make as function config to dotfiles. +### make a -h flag. + +it will says + +`save_config [-h] {deploy|save}` diff --git a/config/files.conf b/config/files.conf index c7cf623..a68b3da 100644 --- a/config/files.conf +++ b/config/files.conf @@ -8,21 +8,21 @@ _GIT_FOLDER="${HOME}/Documents/git" # d for directory, # f for file -_INSTRUCTIONS="u dotfiles -d ${HOME}/.config/alacritty dotfiles/dotconfig/alacritty -d ${HOME}/.config/eww dotfiles/dotconfig/eww -d ${HOME}/.config/hypr dotfiles/dotconfig/hypr -d ${HOME}/.config/nvim dotfiles/dotconfig/nvim -d ${HOME}/.config/gotop dotfiles/dotconfig/gotop -d ${HOME}/.config/waybar dotfiles/dotconfig/waybar -d ${HOME}/.config/conky dotfiles/dotconfig/conky -f ${HOME}/.bashrc dotfiles/dotscripts/bash/.bashrc -f ${HOME}/.bash_profile dotfiles/dotscripts/bash/.bash_profile -d ${HOME}/.local/bin dotfiles/dotlocal/bin -d /etc/ly dotfiles/dotetc/ly -f /etc/makepkg.conf dotfiles/dotetc/makepkg.conf -f /etc/pacman.conf dotfiles/dotetc/makepkg.conf -f /etc/doas.conf dotfiles/dotetc/doas.conf" +_INSTRUCTIONS="uu dotfiles +du ${HOME}/.config/alacritty dotfiles/dotconfig/alacritty +du ${HOME}/.config/eww dotfiles/dotconfig/eww +du ${HOME}/.config/hypr dotfiles/dotconfig/hypr +du ${HOME}/.config/nvim dotfiles/dotconfig/nvim +du ${HOME}/.config/gotop dotfiles/dotconfig/gotop +du ${HOME}/.config/waybar dotfiles/dotconfig/waybar +du ${HOME}/.config/conky dotfiles/dotconfig/conky +fu ${HOME}/.bashrc dotfiles/dotscripts/bash/.bashrc +fu ${HOME}/.bash_profile dotfiles/dotscripts/bash/.bash_profile +du ${HOME}/.local/bin dotfiles/dotlocal/bin +dr /etc/ly dotfiles/dotetc/ly +fr /etc/makepkg.conf dotfiles/dotetc/makepkg.conf +fr /etc/pacman.conf dotfiles/dotetc/pacman.conf +fr /etc/doas.conf dotfiles/dotetc/doas.conf" # Use `git pull ~/Documents/git/${}` for u -> OK # Use `install -Dm644 ` for f -> OK diff --git a/save_config_file b/save_config_file index 088ca0b..f2e6d4c 100755 --- a/save_config_file +++ b/save_config_file @@ -11,27 +11,38 @@ CONFIG_PATH="./config" #echo "$_GIT_FOLDER" #echo "$_INSTRUCTIONS" -while VAR= read -r line; -do - order="$(echo $line | cut -d ' ' -f 1)" - operand_1="$(echo $line | cut -d ' ' -f 2)" - operand_2="$(echo $line | cut -d ' ' -f 3)" +function deploy { - if [ "$order" = "d" ] - then - cp -Rf ${_GIT_FOLDER}/${operand_2}/* ${operand_1} - elif [ "$order" = "f" ] - then - install -Dm644 ${_GIT_FOLDER}/${operand_2} ${operand_1} - elif [ "$order" = "u" ] - then - cd "${_GIT_FOLDER}/${operand_1}" - git pull - cd - - else - echo "Err, $order uknown" - echo ".. ${order} ${operand_1} ${operand_2} .."; - fi + while VAR= read -r line; + do + order="$(echo $line | cut -d ' ' -f 1)" + operand_1="$(echo $line | cut -d ' ' -f 2)" + operand_2="$(echo $line | cut -d ' ' -f 3)" + + if [ "$order" = "du" ] + then + cp -Rf ${_GIT_FOLDER}/${operand_2}/* ${operand_1} + elif [ "$order" = "fu" ] + then + install -Dm644 ${_GIT_FOLDER}/${operand_2} ${operand_1} + elif [ "$order" = "dr" ] + then + doas cp -Rf ${_GIT_FOLDER}/${operand_2}/* ${operand_1} + elif [ "$order" = "fr" ] + then + doas install -Dm644 ${_GIT_FOLDER}/${operand_2} ${operand_1} + elif [ "$order" = "uu" ] + then + cd "${_GIT_FOLDER}/${operand_1}" + git pull + cd - + else + echo "Err, $order uknown" + echo ".. ${order} ${operand_1} ${operand_2} .."; + fi -done <<< "$_INSTRUCTIONS" + done <<< "$_INSTRUCTIONS" +} + +deploy