about summary refs log tree commit diff stats
path: root/home-manager/packages/scripts/apps/deprecated/riR
diff options
context:
space:
mode:
Diffstat (limited to 'home-manager/packages/scripts/apps/deprecated/riR')
-rwxr-xr-xhome-manager/packages/scripts/apps/deprecated/riR/compare_all_files(has_been_riR)87
-rwxr-xr-xhome-manager/packages/scripts/apps/deprecated/riR/config147
-rwxr-xr-xhome-manager/packages/scripts/apps/deprecated/riR/lf-move-fill(has_been_riR)40
3 files changed, 274 insertions, 0 deletions
diff --git a/home-manager/packages/scripts/apps/deprecated/riR/compare_all_files(has_been_riR) b/home-manager/packages/scripts/apps/deprecated/riR/compare_all_files(has_been_riR)
new file mode 100755
index 00000000..023a2bbf
--- /dev/null
+++ b/home-manager/packages/scripts/apps/deprecated/riR/compare_all_files(has_been_riR)
@@ -0,0 +1,87 @@
+#! /bin/bash
+
+tmp=$(mktemp)
+tmp2=$(mktemp)
+pstr="[=======================================================================]"
+printf "Path to filter: "
+read path
+
+## USE FIND INSTEAD OF LS
+cd $path
+results
+echo "" > results 
+
+declare weirdchars=" &\'"
+
+function normalise_and_rename() {
+  declare -a list=("${!1}")
+      for fileordir in "${list[@]}";
+      do
+          newname="${fileordir//[${weirdchars}]/_}"
+          [[ ! -a "$newname" ]] && \
+            mv "$fileordir" "$newname" || \
+                echo "Skipping existing file, $newname."
+      done
+}
+
+declare -a dirs files
+
+while IFS= read -r -d '' dir; do
+    dirs+=("$dir")
+done < <(find -type d -print0 | sort -z)
+
+normalise_and_rename dirs[@]
+
+while IFS= read -r -d '' file; do
+    files+=("$file")
+done < <(find -type f -print0 | sort -z)
+
+normalise_and_rename files[@]
+
+find $path > $tmp 
+total=$(cat $tmp | wc -l)
+#ls  -RAx1 --group-directories-first $path | awk NF | awk ' !/\//' > $tmp
+#cat $tmp
+#exit
+for ((i = 1; i <= $(cat $tmp | wc -l); i++))
+do
+     FILE1=$(cat $tmp | awk -v n=$i 'NR == n {printf $0}') 
+     printf "\r%3d.%1d%% %.${pd}s" $(( $i * 100 / $total )) $(( ($i * 1000 / $total) % 10 )) $pstr
+        if [ -d ${FILE1} ]; then
+           printf '%s is a Directory\n' "$FILE1"
+        else
+            echo ${FILE1} >> $tmp2
+        fi
+done
+echo "##########################################################################################################################################"
+echo "changing to search"
+total=$(cat $tmp2 | wc -l)
+
+for ((i = 1; i <= $(cat $tmp2 | wc -l); i++))
+do
+        FILE1=$(cat $tmp2 | awk -v n=$i 'NR == n {printf $0}') 
+        printf "total : %3d.%1d%% %.${pd}s\n" $(( $i * 100 / $total )) $(( ($i * 1000 / $total) % 10 )) $pstr
+
+        for ((x = 1; x <= $(cat $tmp2 | wc -l); x++))
+        do
+                FILE2=$(cat $tmp2 | awk -v n=$x 'NR == n {printf $0}') 
+                printf "\r%3d.%1d%% %.${pd}s" $(( $x * 100 / $total )) $(( ($x * 1000 / $total) % 10 )) $pstr
+                if [ $x -eq $i ]; then
+                    ((x=x+1))
+                    FILE2=$(cat $tmp2 | awk -v n=$x 'NR == n {printf $0}') 
+                elif [ $(wc -c $FILE2 | awk '{print $1}') != $(wc -c $FILE1 | awk '{print $1}')  ]; then 
+                    :
+                else
+                    if cmp --silent "$FILE1" "$FILE2"; then
+                         printf ' %s \n'  "$FILE2" >> results 
+                        
+                    fi
+                fi
+        done
+done
+echo 
+echo "#########################################################################"
+
+cat $dir 
+rm $tmp
+rm $tmp2
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
diff --git a/home-manager/packages/scripts/apps/deprecated/riR/lf-move-fill(has_been_riR) b/home-manager/packages/scripts/apps/deprecated/riR/lf-move-fill(has_been_riR)
new file mode 100755
index 00000000..8a216b6b
--- /dev/null
+++ b/home-manager/packages/scripts/apps/deprecated/riR/lf-move-fill(has_been_riR)
@@ -0,0 +1,40 @@
+#!/bin/sh
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+. ~/.local/lib/shell/lib
+
+tmp=$(mktemp);
+out=$(mktemp);
+clean $XDG_CONFIG_HOME/lf/rel_dirs > $tmp;
+
+get_hot_key() {
+    printf g
+    if ! [ "$i" = "$(readlink -f "$(cat $tmp | sed -n -e ${a}p)")" ];then 
+        printf "%s" "$(basename "$(cat $tmp | sed -n -e ${a}p)" | cut -c 1)"; # i.e. /home/dt/school
+    fi
+    #if ! [ "$(realpath i)" = "$(cat $tmp | sed -n -e ${a}p)" ];then
+    # i = /home/dt/school/informatik
+        printf "%s" "$(basename $i | cut -c 1)";
+        printf "%s" "$(basename $i | cut -c 2)";
+    #fi
+    if [ $i = "$(cat $tmp | sed -n -e ${1}p)" ];then
+        printf '.';
+    fi
+
+}
+
+
+for a in $(seq "$(cat $tmp | wc -l )");do
+    echo $a >> $out;
+
+    while IFS= read -r i;do
+        printf "map %s cd %s\n" "$(get_hot_key "$a")" "$i" >> $out;
+    done < "$(tmp find "$(cat $tmp | sed -n -e ${a}p)" -maxdepth 1)"
+    echo >> $out;
+done
+
+cat $out # | awk '{print $2}' | sort | uniq -d;
+
+rm $tmp;
+rm $out;
+if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi