diff options
author | typebrook <typebrook@gmail.com> | 2020-05-15 21:33:06 +0800 |
---|---|---|
committer | typebrook <typebrook@gmail.com> | 2020-05-15 21:33:06 +0800 |
commit | 0c6b65a9d78a108c465a0a7274600464c24fb39a (patch) | |
tree | 5e30812b745781cc44189786c4fb8c8cd71aceb9 | |
parent | b807ca84288b7a2d45e263416219d536ffd1b6dc (diff) |
Remove Bash-Snippets related code
-rwxr-xr-x | gist | 56 |
1 files changed, 2 insertions, 54 deletions
@@ -34,8 +34,6 @@ | |||
34 | # user, u <USER> Get list of gists with a given Github user | 34 | # user, u <USER> Get list of gists with a given Github user |
35 | # github, G <INDEX> Export selected gist as a new Github repo | 35 | # github, G <INDEX> Export selected gist as a new Github repo |
36 | # help, h Show this help message | 36 | # help, h Show this help message |
37 | # version Get the tool version | ||
38 | # update Update Bash-Snippet Tools | ||
39 | # | 37 | # |
40 | # Example: | 38 | # Example: |
41 | # gist fetch (update the list of gists from github.com) | 39 | # gist fetch (update the list of gists from github.com) |
@@ -55,7 +53,6 @@ | |||
55 | # TODO codebase statistics, like C++ or something | 53 | # TODO codebase statistics, like C++ or something |
56 | # TODO migrate to gh-page, with install.sh and check_md5 in README | 54 | # TODO migrate to gh-page, with install.sh and check_md5 in README |
57 | 55 | ||
58 | currentVersion="1.23.0" | ||
59 | configuredClient="" | 56 | configuredClient="" |
60 | 57 | ||
61 | NAME=${GISTSCRIPT:-$(basename $0)} #show hint and helper message with current script name | 58 | NAME=${GISTSCRIPT:-$(basename $0)} #show hint and helper message with current script name |
@@ -73,7 +70,6 @@ fi | |||
73 | 70 | ||
74 | # Default configuration | 71 | # Default configuration |
75 | [[ ! -t 1 && -z $hint ]] && hint=false | 72 | [[ ! -t 1 && -z $hint ]] && hint=false |
76 | auto_sync=true # automatically clone the gist repo | ||
77 | protocol=https | 73 | protocol=https |
78 | 74 | ||
79 | # Shell configuration | 75 | # Shell configuration |
@@ -152,50 +148,6 @@ _process_json() { | |||
152 | return "$?" | 148 | return "$?" |
153 | } | 149 | } |
154 | 150 | ||
155 | update() { | ||
156 | # Author: Alexander Epstein https://github.com/alexanderepstein | ||
157 | # Update utility version 2.2.0 | ||
158 | # To test the tool enter in the defualt values that are in the examples for each variable | ||
159 | repositoryName="Bash-Snippets" #Name of repostiory to be updated ex. Sandman-Lite | ||
160 | githubUserName="alexanderepstein" #username that hosts the repostiory ex. alexanderepstein | ||
161 | nameOfInstallFile="install.sh" # change this if the installer file has a different name be sure to include file extension if there is one | ||
162 | latestVersion=$(httpGet https://api.github.com/repos/$githubUserName/$repositoryName/tags | grep -Eo '"name":.*?[^\\]",'| head -1 | grep -Eo "[0-9.]+" ) #always grabs the tag without the v option | ||
163 | |||
164 | if [[ $currentVersion == "" || $repositoryName == "" || $githubUserName == "" || $nameOfInstallFile == "" ]]; then | ||
165 | echo "Error: update utility has not been configured correctly." >&2 | ||
166 | exit 1 | ||
167 | elif [[ $latestVersion == "" ]]; then | ||
168 | echo "Error: no active internet connection" >&2 | ||
169 | exit 1 | ||
170 | else | ||
171 | if [[ $latestVersion != "$currentVersion" ]]; then | ||
172 | echo "Version $latestVersion available" | ||
173 | echo -n "Do you wish to update $repositoryName [Y/n]: " | ||
174 | read -r answer | ||
175 | if [[ $answer == [Yy] ]]; then | ||
176 | cd ~ || { echo 'Update Failed'; exit 1; } | ||
177 | if [[ -d ~/$repositoryName ]]; then rm -r -f $repositoryName || { echo "Permissions Error: try running the update as sudo"; exit 1; } ; fi | ||
178 | echo -n "Downloading latest version of: $repositoryName." | ||
179 | # shellcheck disable=SC2015 | ||
180 | git clone -q "https://github.com/$githubUserName/$repositoryName" && touch .BSnippetsHiddenFile || { echo "Failure!"; exit 1; } & | ||
181 | while [ ! -f .BSnippetsHiddenFile ]; do { echo -n "."; sleep 2; };done | ||
182 | rm -f .BSnippetsHiddenFile | ||
183 | echo "Success!" | ||
184 | cd $repositoryName || { echo 'Update Failed'; exit 1; } | ||
185 | git checkout "v$latestVersion" 2> /dev/null || git checkout "$latestVersion" 2> /dev/null || echo "Couldn't git checkout to stable release, updating to latest commit." | ||
186 | chmod a+x install.sh #this might be necessary in your case but wasnt in mine. | ||
187 | ./$nameOfInstallFile "update" || exit 1 | ||
188 | cd .. | ||
189 | rm -r -f $repositoryName || { echo "Permissions Error: update succesfull but cannot delete temp files located at ~/$repositoryName delete this directory with sudo"; exit 1; } | ||
190 | else | ||
191 | exit 1 | ||
192 | fi | ||
193 | else | ||
194 | echo "$repositoryName is already the latest version" | ||
195 | fi | ||
196 | fi | ||
197 | } | ||
198 | |||
199 | # Handle configuration cases | 151 | # Handle configuration cases |
200 | _configure() { | 152 | _configure() { |
201 | [[ $# == 0 ]] && (${EDITOR:-vi} "$CONFIG") && return 0 | 153 | [[ $# == 0 ]] && (${EDITOR:-vi} "$CONFIG") && return 0 |
@@ -297,7 +249,7 @@ _color_description_title() { | |||
297 | # Return git status of a given repo | 249 | # Return git status of a given repo |
298 | _check_repo_status() { | 250 | _check_repo_status() { |
299 | if [[ ! -d $1 ]]; then | 251 | if [[ ! -d $1 ]]; then |
300 | if [[ $auto_sync == 'true' ]]; then | 252 | if [[ $auto_sync != false ]]; then |
301 | echo "\e[32m[cloning]\e[0m"; | 253 | echo "\e[32m[cloning]\e[0m"; |
302 | else | 254 | else |
303 | echo "\e[32m[Not cloned yet]\e[0m"; | 255 | echo "\e[32m[Not cloned yet]\e[0m"; |
@@ -455,7 +407,7 @@ _fetch_gists() { | |||
455 | sed -i'' -Ee "/^$mark/ d" $INDEX && echo "$result" >> $INDEX | 407 | sed -i'' -Ee "/^$mark/ d" $INDEX && echo "$result" >> $INDEX |
456 | hint=$hint _show_list | 408 | hint=$hint _show_list |
457 | 409 | ||
458 | [[ $auto_sync == 'true' ]] && (_sync_repos &> /dev/null &) | 410 | [[ $auto_sync != false ]] && (_sync_repos &> /dev/null &) |
459 | true | 411 | true |
460 | } | 412 | } |
461 | 413 | ||
@@ -911,10 +863,6 @@ case "$1" in | |||
911 | mark=.; _gists_with_range "$@" ;; | 863 | mark=.; _gists_with_range "$@" ;; |
912 | last | L) | 864 | last | L) |
913 | _access_last_index "$@" ;; | 865 | _access_last_index "$@" ;; |
914 | version) | ||
915 | echo "Version $currentVersion" ;; | ||
916 | update) | ||
917 | update ;; | ||
918 | help | h) | 866 | help | h) |
919 | usage ;; | 867 | usage ;; |
920 | *) | 868 | *) |