diff options
| author | typebrook <typebrook@gmail.com> | 2020-04-01 09:44:27 +0800 |
|---|---|---|
| committer | typebrook <typebrook@gmail.com> | 2020-04-07 11:44:14 +0800 |
| commit | a3225f170749e09b8986fe8d2862d06ca59dabed (patch) | |
| tree | a627c931b0e2d6a0a617bbb024aadc8225e41b04 /README.md | |
| parent | 2ca0a674f43a18d1e52b8038513faf48ed7ace35 (diff) | |
update
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 50 |
1 files changed, 34 insertions, 16 deletions
| @@ -1,5 +1,6 @@ | |||
| 1 | # gist - Manage your gist like a pro | 1 | # [[gist]] - Manage your gist like a pro |
| 2 | ## Getting started | 2 | ## Getting started |
| 3 | |||
| 3 | ```bash | 4 | ```bash |
| 4 | # fetch your gists and clone them into ~/gist as git repos | 5 | # fetch your gists and clone them into ~/gist as git repos |
| 5 | gist fetch | 6 | gist fetch |
| @@ -9,10 +10,8 @@ gist | |||
| 9 | gist new | 10 | gist new |
| 10 | # create private gist with files 'foo' and 'bar' | 11 | # create private gist with files 'foo' and 'bar' |
| 11 | gist new -p foo bar | 12 | gist new -p foo bar |
| 12 | # get the path of cloned repo of your third gist | 13 | # get the path and cd to cloned repo with subshell |
| 13 | gist 3 | 14 | gist 3 |
| 14 | # cd to the cloned repo | ||
| 15 | cd `gist 3` | ||
| 16 | # push changes in your third gist to the remote repo | 15 | # push changes in your third gist to the remote repo |
| 17 | gist push 3 | 16 | gist push 3 |
| 18 | # update the description of your third gist | 17 | # update the description of your third gist |
| @@ -26,8 +25,9 @@ gist github 3 | |||
| 26 | # For more detail, read the helper message | 25 | # For more detail, read the helper message |
| 27 | gist help | 26 | gist help |
| 28 | ``` | 27 | ``` |
| 28 | |||
| 29 | ## Commands | 29 | ## Commands |
| 30 | ### Update information and clone gists from Github | 30 | ### Update and clone gists from Github |
| 31 | Run `gist fetch` to fetch your all gists with Github API and keep short information for each gist in a index file inside a given folder. (default to `~/gist/index`) | 31 | Run `gist fetch` to fetch your all gists with Github API and keep short information for each gist in a index file inside a given folder. (default to `~/gist/index`) |
| 32 | - Automatically Clone/Pull each gist with git into a given folder. (default to `~/gist/`) | 32 | - Automatically Clone/Pull each gist with git into a given folder. (default to `~/gist/`) |
| 33 | - Run `gist fetch star` to fetch you starred gist | 33 | - Run `gist fetch star` to fetch you starred gist |
| @@ -35,18 +35,21 @@ Run `gist fetch` to fetch your all gists with Github API and keep short informat | |||
| 35 | 35 | ||
| 36 | ### List your gists | 36 | ### List your gists |
| 37 | Run `gist` to read index file (default to `~/gist/index`) and list your gists with the folloing format: | 37 | Run `gist` to read index file (default to `~/gist/index`) and list your gists with the folloing format: |
| 38 | ``` | 38 | ``` |
| 39 | [index] [gist-URL] [files-number] [comments-number] [description] | 39 | [index] [gist-URL] [files-number] [comments-number] [description] |
| 40 | ``` | 40 | ``` |
| 41 | like following: | ||
| 42 |  | ||
| 43 | 41 | ||
| 44 | - Use `gist star` to show your starred gist | 42 | like the following: |
| 43 | |||
| 44 |  | ||
| 45 | |||
| 46 | - Use `gist star` to show your starred gists | ||
| 47 | - Use `gist all` to show your and starred gists | ||
| 45 | - Index with prefix `s` is a starred gist, index with prefix `p` is a private gist | 48 | - Index with prefix `s` is a starred gist, index with prefix `p` is a private gist |
| 46 | - There are colorful hints for each gist in the following cases: | 49 | - There are colorful hints for each gist in the following cases: |
| 47 | - **working:** some changes are made locally but not yet do `git commit`, or you are not in `master` branch | 50 | - **working:** some changes are made locally but not yet do `git commit`, or you are not in `master` branch |
| 48 | - **ahead:** your local head is yet to be applied to upstream | 51 | - **ahead:** your local **HEAD** is yet to be applied to upstream |
| 49 | - **outdated:** your local head is differs from the last fetched gists, do `gist fetch` to refresh index file and pull if needed | 52 | - **outdated:** your local **HEAD** is differs from the last fetched gists, do `gist fetch` to refresh index file and pull if needed |
| 50 | 53 | ||
| 51 | ### Create a new gist | 54 | ### Create a new gist |
| 52 | Run `gist new` to create a new gist | 55 | Run `gist new` to create a new gist |
| @@ -109,11 +112,11 @@ Use `gist config auto_sync false` to disable this feature. | |||
| 109 | 112 | ||
| 110 | For example, you can use the following command to set the action for: | 113 | For example, you can use the following command to set the action for: |
| 111 | **print the filename and its content of all files inside the given gist** | 114 | **print the filename and its content of all files inside the given gist** |
| 112 | ``` | 115 | ```bash |
| 113 | gist config action 'tail -n +1 *' | 116 | gist config action 'tail -n +1 *' |
| 114 | ``` | 117 | ``` |
| 115 | or do | 118 | or do |
| 116 | ``` | 119 | ```bash |
| 117 | gist config action '${EDITOR:-vi} .' | 120 | gist config action '${EDITOR:-vi} .' |
| 118 | ``` | 121 | ``` |
| 119 | That is, use default editor or vi (if not being set) to open the cloned repo. | 122 | That is, use default editor or vi (if not being set) to open the cloned repo. |
| @@ -134,6 +137,21 @@ valid values are: | |||
| 134 | For example, use `gist config protocol ssh` to use SSH protocol instead. | 137 | For example, use `gist config protocol ssh` to use SSH protocol instead. |
| 135 | 138 | ||
| 136 | ## Tips | 139 | ## Tips |
| 140 | ### Index Range | ||
| 141 | ```bash | ||
| 142 | # show gists from index 5 | ||
| 143 | gist 5- | ||
| 144 | # show starred gists from index s3 | ||
| 145 | gist s3- | ||
| 146 | # only show gists with index 5 to 10 | ||
| 147 | gist 5-10 | ||
| 148 | ``` | ||
| 149 | |||
| 150 | ### Filter | ||
| 151 | ```bash | ||
| 152 | gist tag tag1 | gist grep pattern1 | gist lan SHELL | ||
| 153 | ``` | ||
| 154 | |||
| 137 | ### Git Branching | 155 | ### Git Branching |
| 138 | Each gist is a git repository. Although there are some limits on `git push`, like sub-directory. But guess what? Push another branch to `github.com` is allowed. So why not use this feature for your gist workflow? | 156 | Each gist is a git repository. Although there are some limits on `git push`, like sub-directory. But guess what? Push another branch to `github.com` is allowed. So why not use this feature for your gist workflow? |
| 139 | 157 | ||
| @@ -152,12 +170,12 @@ But since `gist` is a bash script which goes in subshell, if you want to achieve | |||
| 152 | 170 | ||
| 153 | ### Suppress hint | 171 | ### Suppress hint |
| 154 | If [action](#action) is not configured, there is always a hint to show how to configure it. The following command can suppress it with a simple action that does nothing. | 172 | If [action](#action) is not configured, there is always a hint to show how to configure it. The following command can suppress it with a simple action that does nothing. |
| 155 | ``` | 173 | ```bash |
| 156 | gist config action 'true' | 174 | gist config action 'true' |
| 157 | ``` | 175 | ``` |
| 158 | 176 | ||
| 159 | There are serveral environment variables can suppress hint or user confirm, like: | 177 | There are serveral environment variables can suppress hint or user confirm, like: |
| 160 | ``` | 178 | ```bash |
| 161 | # show list without hint | 179 | # show list without hint |
| 162 | hint=false gist | 180 | hint=false gist |
| 163 | 181 | ||
| @@ -175,6 +193,6 @@ I strongly recommend using [`tig`](https://github.com/jonas/tig) as [action](#ac | |||
| 175 | 193 | ||
| 176 | If [`tig`](https://github.com/jonas/tig) is installed, run the following command to configure it as custom action: | 194 | If [`tig`](https://github.com/jonas/tig) is installed, run the following command to configure it as custom action: |
| 177 | 195 | ||
| 178 | ``` | 196 | ```bash |
| 179 | gist config action 'tig -all' | 197 | gist config action 'tig -all' |
| 180 | ``` | 198 | ``` |