diff options
author | typebrook <typebrook@gmail.com> | 2020-04-11 23:10:57 +0800 |
---|---|---|
committer | typebrook <typebrook@gmail.com> | 2020-04-11 23:10:57 +0800 |
commit | 9af58572e7d99edd5f0f178bd789b1d36a8e63c6 (patch) | |
tree | c2fc645c23d2c93827b021902267fd6fe50778cb | |
parent | 6acdd86d1fede147dd93fff2f9ad86a5f2f2337c (diff) |
Add configuration 'show_untagged'
-rw-r--r-- | README.md | 5 | ||||
-rwxr-xr-x | gist | 9 |
2 files changed, 10 insertions, 4 deletions
@@ -164,6 +164,11 @@ valid values are: | |||
164 | 164 | ||
165 | For example, use `gist config protocol ssh` to use SSH protocol instead. | 165 | For example, use `gist config protocol ssh` to use SSH protocol instead. |
166 | 166 | ||
167 | ### show_untagged | ||
168 | **[Optional]** Whether to show untagged gists when using [`gist tag`](#List-gists-with-tags). Default to be `true` | ||
169 | |||
170 | Use `gist config show_untagged false` to disable this feature. | ||
171 | |||
167 | ## Filter gists | 172 | ## Filter gists |
168 | ### Filter by tags | 173 | ### Filter by tags |
169 | `gist` treats **trailing hashtags** inside gist description as tags. For example, if a description is: | 174 | `gist` treats **trailing hashtags** inside gist description as tags. For example, if a description is: |
@@ -30,7 +30,7 @@ | |||
30 | # delete, D <INDEX>... [--force] Delete gists by given indices | 30 | # delete, D <INDEX>... [--force] Delete gists by given indices |
31 | # push, P <INDEX> Push changes by git (well, better to make commit by youself) | 31 | # push, P <INDEX> Push changes by git (well, better to make commit by youself) |
32 | # clean, C Clean local repos of removed gists | 32 | # clean, C Clean local repos of removed gists |
33 | # config, c [token|user|folder|auto_sync|EDITOR|action|protocol [value]] Do configuration | 33 | # config, c [token|user|folder|auto_sync|EDITOR|action|protocol|show_untagged [value]] Do configuration |
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> Import selected gist as a new Github repo | 35 | # github, G <INDEX> Import selected gist as a new Github repo |
36 | # help, h Show this help message | 36 | # help, h Show this help message |
@@ -170,15 +170,15 @@ update() { | |||
170 | _configure() { | 170 | _configure() { |
171 | [[ $# == 0 ]] && (${EDITOR:-vi} "$CONFIG") && return 0 | 171 | [[ $# == 0 ]] && (${EDITOR:-vi} "$CONFIG") && return 0 |
172 | 172 | ||
173 | local valid_keys='user|token|folder|auto_sync|EDITOR|action|protocol' | 173 | local valid_keys='user|token|folder|auto_sync|EDITOR|action|protocol|show_untagged' |
174 | local key=$1; local value="$2" | 174 | local key=$1; local value="$2" |
175 | if [[ $key =~ ^($valid_keys)$ ]]; then | 175 | if [[ $key =~ ^($valid_keys)$ ]]; then |
176 | if [[ $key == 'user' ]]; then | 176 | if [[ $key == 'user' ]]; then |
177 | [[ -z $value ]] && echo 'Must specify username' >&2 && return 1 | 177 | [[ -z $value ]] && echo 'Must specify username' >&2 && return 1 |
178 | elif [[ $key == 'token' ]]; then | 178 | elif [[ $key == 'token' ]]; then |
179 | [[ ${#value} -ne 40 ]] && echo 'Invalid token format, it is not 40 chars' >&2 && return 1 | 179 | [[ ${#value} -ne 40 ]] && echo 'Invalid token format, it is not 40 chars' >&2 && return 1 |
180 | elif [[ $key == 'auto_sync' ]]; then | 180 | elif [[ $key =~ ^(auto_sync|show_untagged)$ ]]; then |
181 | [[ ! $value =~ ^(true|false)$ ]] && echo 'auto_sync must be either true or false' >&2 && return 1 | 181 | [[ ! $value =~ ^(true|false)$ ]] && echo "$key must be either true or false" >&2 && return 1 |
182 | elif [[ $key == 'protocol' ]]; then | 182 | elif [[ $key == 'protocol' ]]; then |
183 | [[ ! $value =~ ^(https|ssh)$ ]] && echo 'protocol must be either https or ssh' >&2 && return 1 | 183 | [[ ! $value =~ ^(https|ssh)$ ]] && echo 'protocol must be either https or ssh' >&2 && return 1 |
184 | fi | 184 | fi |
@@ -309,6 +309,7 @@ _show_list() { | |||
309 | 309 | ||
310 | local message=$url | 310 | local message=$url |
311 | if [[ $display == 'tag' ]]; then | 311 | if [[ $display == 'tag' ]]; then |
312 | [[ $show_untagged == 'false' && -z $hashtags ]] && continue | ||
312 | message="$hashtags"; local width=45; local align=' '; extra=''; | 313 | message="$hashtags"; local width=45; local align=' '; extra=''; |
313 | elif [[ $display == 'language' ]]; then | 314 | elif [[ $display == 'language' ]]; then |
314 | message="$(tr ',' '\n' <<< $file_array | sed -Ee 's/.+@/#/' | uniq | xargs)" | 315 | message="$(tr ',' '\n' <<< $file_array | sed -Ee 's/.+@/#/' | uniq | xargs)" |