aboutsummaryrefslogtreecommitdiffstats
path: root/home-manager/packages/scripts/apps/deprecated/riR/config
diff options
context:
space:
mode:
Diffstat (limited to 'home-manager/packages/scripts/apps/deprecated/riR/config')
-rwxr-xr-xhome-manager/packages/scripts/apps/deprecated/riR/config147
1 files changed, 147 insertions, 0 deletions
diff --git a/home-manager/packages/scripts/apps/deprecated/riR/config b/home-manager/packages/scripts/apps/deprecated/riR/config
new file mode 100755
index 00000000..b5607a16
--- /dev/null
+++ b/home-manager/packages/scripts/apps/deprecated/riR/config
@@ -0,0 +1,147 @@
+#!/bin/sh
+# shellcheck source=/dev/null
+. ~/.local/lib/shell/lib
+
+git_repo_home="$XDG_CONFIG_HOME"/git_repo
+[ -d "$git_repo_home" ] || mkdir "$git_repo_home"
+launch_dir="$(dirname "$(readlink -f "$0")")"
+
+. "$launch_dir"/utils
+
+add() {
+ name=$(basename "$1")
+ while clean files | awk '{print $1}' | grep -w "^$name$" > /dev/null;do
+ printf "\"%s\" already exists, new name for link: " "$name"
+ read -r name
+ done
+ cp "$1" "$git_repo_home"/"$name"
+ {
+ printf "%s " "$name";
+ printf "%s " "$1";
+ printf "%s\n" "$(stat -c "%a" "$1")"
+ } >> "$git_repo_home"/files
+}
+
+remove() {
+ tmp=$(grepw "$1")
+ if pre_check "$tmp";then
+ file_path="$(awk '{print $2}' "$tmp")"
+ file_name="$(awk '{print $1}' "$tmp")"
+
+ rm "$git_repo_home"/"$file_name"
+ grep -v "$1" "$git_repo_home"/files > "$tmp"
+ cat "$tmp" > "$git_repo_home"/files
+ fi
+}
+
+gitw() {
+ git --git-dir="$git_repo_home"/.git --work-tree="$git_repo_home" "$@"
+}
+
+deploy_files() {
+ tmp=$(grepw "$1")
+ if pre_check "$tmp";then
+ file_path="$(awk '{print $2}' "$tmp")"
+ file_name="$(awk '{print $1}' "$tmp")"
+ file_bits="$(awk '{print $3}' "$tmp")"
+
+ if [ -e "$file_path" ] && ! cmp "$git_repo_home"/"$file_name" "$file_path" > /dev/null;then
+ if overwrite_check "$file_path" "$file_name" "file" ;then
+ cp -f "$git_repo_home"/"$file_name" "$file_path"
+ fi
+ elif cmp "$git_repo_home"/"$file_name" "$file_path" > /dev/null;then
+ [ "$AUTO_GEN" = "Y" ] || msg "File is already deployed"
+ else
+ cp "$git_repo_home"/"$file_name" "$file_path"
+ chmod "$file_bits" "$file_path"
+ fi
+ fi
+}
+
+update() {
+ tmp=$(grepw "$1")
+ if pre_check "$tmp";then
+ file_path="$(awk '{print $2}' "$tmp")"
+ file_name="$(awk '{print $1}' "$tmp")"
+
+ if [ -e "$file_path" ] && ! cmp "$git_repo_home"/"$file_name" "$file_path" > /dev/null;then
+ if overwrite_check "$file_path" "$file_name" "backup" ;then
+ cp -f "$file_path" "$git_repo_home"/"$file_name"
+ fi
+ elif cmp "$git_repo_home"/"$file_name" "$file_path" > /dev/null;then
+ [ "$AUTO_GEN" = "Y" ] || msg "File does not need to be updated"
+ else
+ die "File does not exist on the system!"
+ fi
+ fi
+}
+
+usage() {
+ cat << EO
+This is config, an easy dotfiles backup service!
+
+help Outputs this help
+add Adds the specified files
+remove Removes the specified files
+commit Same as 'config git commit'
+git Runs git with the arguments in the backup directory
+deploy Copies the specified file, or all files to their location
+dump Dumps the 'files' file
+update Updates the specified file, or all files if none are supplied
+grep Searches for the supplied string in the 'files' file
+EO
+exit "$1"
+}
+
+case "$1" in
+ "help")
+ shift 1
+ usage 0
+ ;;
+ "add")
+ shift 1
+ while [ "$1" != "" ];do
+ add "$(readlink -f "$1")"
+ shift 1
+ done
+ ;;
+ "remove")
+ shift 1
+ shift_througth "remove" "$@"
+ ;;
+ "commit")
+ shift 1
+ gitw commit
+ ;;
+ "git")
+ shift 1
+ gitw "$@"
+ ;;
+ "deploy")
+ shift 1
+ shift_througth "deploy_files" "$@"
+ ;;
+ "dump")
+ shift 1
+ cat "$git_repo_home"/files
+ ;;
+ "update")
+ shift 1
+ shift_througth "update" "$@"
+ ;;
+ "grep")
+ shift 1
+ tmp=$(grepw "$1")
+ cat "$tmp"
+ ;;
+ *)
+ echo "Option $1 not recognized!"
+ usage 1
+ ;;
+
+ esac
+
+
+
+
+ if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi