diff options
Diffstat (limited to 'scripts/gist')
-rwxr-xr-x | scripts/gist | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/scripts/gist b/scripts/gist index 3262a76..11fda56 100755 --- a/scripts/gist +++ b/scripts/gist | |||
@@ -128,27 +128,26 @@ _sync_repos() { | |||
128 | _gist_id() { | 128 | _gist_id() { |
129 | GIST_ID=$(cat $index $starred | sed -n "/^$1 / p" | cut -d' ' -f2 | sed -E 's#.*/##') | 129 | GIST_ID=$(cat $index $starred | sed -n "/^$1 / p" | cut -d' ' -f2 | sed -E 's#.*/##') |
130 | if [[ -z $GIST_ID ]]; then | 130 | if [[ -z $GIST_ID ]]; then |
131 | echo Not a valid index: $1 | 131 | echo -e "Not a valid index: \e[31m$1\e[0m" |
132 | echo Use the index number in the first column instead: | 132 | echo Use the index number in the first column instead: |
133 | echo | 133 | echo |
134 | _show_list "$index $starred" | 134 | _show_list "$index $starred" |
135 | return 1 | 135 | exit 1 |
136 | else | ||
137 | echo $GIST_ID | ||
138 | fi | 136 | fi |
139 | } | 137 | } |
140 | 138 | ||
139 | # FIXME error handling | ||
141 | _goto_gist() { | 140 | _goto_gist() { |
142 | GIST_ID=$(_gist_id $1 || return 0) | 141 | _gist_id $1 |
143 | echo This gist is at $folder/$GIST_ID | 142 | echo This gist is at $folder/$GIST_ID |
144 | echo -e "You can use the following command to jump to this directory: \n" | 143 | echo -e "You can run the following command to jump to this directory: \n" |
145 | echo -e " \e[31m. gist $1\e[0m" | 144 | echo -e " \e[32m. gist $1\e[0m" |
146 | echo | 145 | echo |
147 | cd $folder/$GIST_ID && ls && tig --all 2> /dev/null | 146 | cd $folder/$GIST_ID && ls && tig --all 2> /dev/null |
148 | } | 147 | } |
149 | 148 | ||
150 | _delete_gist() { | 149 | _delete_gist() { |
151 | GIST_ID=$(_gist_id $1 || return 0) | 150 | _gist_id $1 |
152 | curl -X DELETE -s -H "$auth_header" $github_api/gists/$GIST_ID && \ | 151 | curl -X DELETE -s -H "$auth_header" $github_api/gists/$GIST_ID && \ |
153 | _update | 152 | _update |
154 | } | 153 | } |
@@ -164,7 +163,7 @@ _clean_repos() { | |||
164 | 163 | ||
165 | # TODO format with simple text | 164 | # TODO format with simple text |
166 | _show_detail() { | 165 | _show_detail() { |
167 | GIST_ID=$(_gist_id $1 || return 0) | 166 | _gist_id $1 |
168 | curl -s -H "$auth_header" $github_api/gists/$GIST_ID |\ | 167 | curl -s -H "$auth_header" $github_api/gists/$GIST_ID |\ |
169 | jq '{site: .html_url, description: .description, public: .public, API: .url, created_at: .created_at, updated_at: .updated_at, files: (.files | keys)}' | 168 | jq '{site: .html_url, description: .description, public: .public, API: .url, created_at: .created_at, updated_at: .updated_at, files: (.files | keys)}' |
170 | 169 | ||
@@ -194,7 +193,7 @@ _create_gist() { | |||
194 | 193 | ||
195 | # update description of a gist | 194 | # update description of a gist |
196 | _edit_gist() { | 195 | _edit_gist() { |
197 | GIST_ID=$(_gist_id $1 || return 0) | 196 | _gist_id $1 |
198 | 197 | ||
199 | echo -n 'Type new description: ' | 198 | echo -n 'Type new description: ' |
200 | read DESC | 199 | read DESC |