summaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/gist18
1 files changed, 9 insertions, 9 deletions
diff --git a/scripts/gist b/scripts/gist
index 72d7ef9..93b1dbd 100755
--- a/scripts/gist
+++ b/scripts/gist
@@ -69,9 +69,9 @@ _auth() {
69 read -sp "Github password: " password < /dev/tty 69 read -sp "Github password: " password < /dev/tty
70 mkdir -p ~/.config && umask 0077 && echo user=$user > $config 70 mkdir -p ~/.config && umask 0077 && echo user=$user > $config
71 71
72 curl https://api.github.com/authorizations \ 72 curl -i https://api.github.com/authorizations \
73 --user "$user:$password" \ 73 --user "$user:$password" \
74 --data "$data" > /dev/null 74 --data "$data" \
75 75
76 read -p "2-factor code: " OTP < /dev/tty 76 read -p "2-factor code: " OTP < /dev/tty
77 curl https://api.github.com/authorizations \ 77 curl https://api.github.com/authorizations \
@@ -110,17 +110,17 @@ _show_list() {
110 cat $1 \ 110 cat $1 \
111 | while read line_num link file_url_array file_num extra description; do 111 | while read line_num link file_url_array file_num extra description; do
112 local repo=$folder/$(echo $link | sed 's#.*/##') 112 local repo=$folder/$(echo $link | sed 's#.*/##')
113 local occupy=0
113 114
114 # if repo is not yet cloned, show green message "Not cloned yet" 115 # if repo is not yet cloned, show green message "Not cloned yet"
115 [[ ! -d $repo ]] && extra="\e[32m[Not cloned yet]\e[0m" 116 [[ ! -d $repo ]] && extra="\e[32m[Not cloned yet]\e[0m" && occupy=17
116 117
117 cd $repo
118 # if there are some changes in git index or working directory, show blue message "working" 118 # if there are some changes in git index or working directory, show blue message "working"
119 [[ -n $(git status --short) ]] 2>/dev/null && extra="\e[36m[working]\e[0m" 119 [[ -n $(cd $repo && git status --short) ]] 2>/dev/null && extra="\e[36m[working]\e[0m" && occupy=10
120 # if there is a commit not yet push, show red message "ahead" 120 # if there is a commit not yet push, show red message "ahead"
121 [[ -n $(git cherry) ]] 2>/dev/null && extra="\e[31m[ahead]\e[0m" 121 [[ -n $(cd $repo && git cherry) ]] 2>/dev/null && extra="\e[31m[ahead]\e[0m" && occupy=8
122 122
123 echo -e $line_num $link $file_num $extra $(echo $description | cut -c -60) 123 echo -e $line_num $link $file_num $extra $(echo $description | cut -c -$(( 60 - $occupy )) )
124 done 124 done
125} 125}
126 126
@@ -135,8 +135,8 @@ _update() {
135 135
136 curl -s -H "$auth_header" $github_api/$route \ 136 curl -s -H "$auth_header" $github_api/$route \
137 | _parse_response | nl -s' ' | sed -E "s/^ */$mark/" > $list_file \ 137 | _parse_response | nl -s' ' | sed -E "s/^ */$mark/" > $list_file \
138 && show_list $list_file \ 138 && _show_list $list_file \
139 || echo Fail to update gists && exit 1 139 || echo Fail to update gists
140 140
141 if [[ $auto_sync != "false" ]]; then (_sync_repos $1 > /dev/null 2>&1 &); fi 141 if [[ $auto_sync != "false" ]]; then (_sync_repos $1 > /dev/null 2>&1 &); fi
142} 142}