-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshellupgit
executable file
·141 lines (107 loc) · 4.12 KB
/
shellupgit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/env bash
generate_toc() {
generate_toc_arrays() {
IFS=''
seg1col=()
linecol=()
seg1old=()
seg2old=()
tabcol=()
while read -r line; do
# if [[ ""$line"" =~ ^\* ]]; then
if [[ "$(echo "$line" | grep -o '^**')" ]]; then
linecol+=("$line")
seg1=$(echo "$line" | sed 's/\ /-/g' | tr -cd '[:alnum:]._-' | sed 's/-//' | sed -e 's/\(.*\)/\L\1/' | sed 's/\.//g')
seg2=$(echo "$line" | sed 's/^\**//g' | sed 's/^\ //')
seg1old+=($seg1)
seg2old+=($seg2)
tab=$(echo "$line" | grep -o '^**' | wc -c)
((tab--))
tab=$(printf "%${tab}c" ' ')
tabcol+=("$tab")
# echo "- [[#$seg1]["$line"]]"
# seg1col=seg1col$seg1
fi
done < "$1"
# echo ${seg1col[1]}
# Create an associative array to keep track of counts
declare -A counts
# Iterate through the original array
for element in "${seg1old[@]}"; do
# Increment the count for this element
((counts["$element"]++))
# Append the count to the element if it's not unique
if ((counts["$element"] == 1)); then
new_element="$element"
elif ((counts["$element"] > 1)); then
((temcou=${counts["$element"]}-1))
new_element="${element}-${temcou}"
else
new_element="$element"
fi
# Add the modified element to the new array
seg1+=("$new_element")
done
echo "* TABLE OF CONTENTS :toc:"
c=0
for line in "${seg1old[@]}"
do
if [[ ${seg1[(($c+1))]} == "table-of-contents-toc" ]]
then
((c++))
else
echo "${tabcol[$c]}- [[#${seg1[(($c+1))]}][${seg2old[$c]}]]" | sed 's/^\ -/-/'
((c++))
fi
done
}
oldtoc="$(sed -n '/^\*\ TABLE\ OF\ CONTENTS/,/^$/p' "$1")"
newtoc="$(generate_toc_arrays "$1")"
oldfile=$(cat "$1")
newfile=${oldfile//"${oldtoc}"/"${newtoc}"}
echo "$newfile" > "$1"
}
cd ~/github/shell || exit
export GNUPGHOME=$(pwd)/.gnupg/
cp -rfv ~/.config/zsh/.profile ~/github/shell
cp -rfv ~/.config/zsh/.zshrc ~/github/shell/
cp -rfv ~/.config/zsh/.zshenv ~/github/shell/
# cp -rfv ~/.p10k.zsh ~/github/shell/
gpg2 -e -r 99F754553DF4C8382876F1F48422C956454840EB ~/.config/zsh/history
mv -fv ~/.config/zsh/history.gpg ~/github/shell/.zsh_history.gpg
gpg2 -e -r 99F754553DF4C8382876F1F48422C956454840EB ~/.config/zsh/.zshrc_private
mv -fv ~/.config/zsh/.zshrc_private.gpg ~/github/shell/.zsh_private.gpg
cp -rfv ~/Documents/BashScript/csp ~/github/shell/bin/c
cp -rfv ~/Documents/BashScript/shellupgit ~/github/shell/shellupgit
cp -rfv "$(which psapp | head -n 1)" ~/github/shell/bin/psapp
generate_toc ~/org/zshrc.org
cp -rfv ~/org/zshrc.org ~/github/shell/
# cp -rfv $(which c | head -n 1) ~/github/shell/bin/c
# cp -rfv $(which shellupgit) ~/github/shell/shellupgit
# mv ~/.zsh_history.gpg ~/github/shell/
# mv ~/.zshrc_private.gpg ~/github/shell/
rm -rfv .gnupg/random_seed
git add ./*
git add ./.*
git status | bat
git fetch && git pull && git commit -am update_"$(date +%s)" && git push
git status | bat
cp -rfv ~/.config/doom/* ~/github/rexdoom/
cp -rfv ~/org/doomemacs.org ~/github/rexdoom/
cd ~/github/rexdoom || exit
git fetch && git pull && git add . && git commit -am update_"$(date +%s)" && git push
cp -rfv "$(which autowallp | head -n 1)" ~/github/autowallp/autowallp
cp -rfv "$(which wallch | head -n 1)" ~/github/autowallp/wallch
cp -rfv ~/org/bashscripts/autowallp.org ~/github/autowallp/README.org
cd ~/github/autowallp || exit
git fetch && git pull && git add . && git commit -am update_"$(date +%s)" && git push
cd ~/github/RexAckermann.github.io/shell/ || exit
git fetch && git pull && git commit -am update_"$(date +%s)" && git push
cd ~/github/RexAckermann.github.io/rexdoom/ || exit
git fetch && git pull && git commit -am update_"$(date +%s)" && git push
cd ~/github/RexAckermann.github.io/autowallp/ || exit
git fetch && git pull && git commit -am update_"$(date +%s)" && git push
cd ~/github/RexAckermann.github.io/ || exit
git fetch && git pull && git commit -am update_"$(date +%s)" && git push
cd ~/.config/mpv/ || exit
git fetch && git pull && git commit -am update_"$(date +%s)" && git push