gist 4.6.2 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +35 -15
- data/bin/gist +9 -11
- data/gist.gemspec +1 -1
- data/lib/gist.rb +97 -31
- data/spec/ghe_spec.rb +12 -5
- data/spec/rawify_spec.rb +10 -1
- data/spec/shorten_spec.rb +11 -2
- data/spec/spec_helper.rb +1 -1
- metadata +3 -7
- data/.gitignore +0 -8
- data/build/gist +0 -2092
- data/build/gist.1 +0 -277
data/build/gist.1
DELETED
@@ -1,277 +0,0 @@
|
|
1
|
-
.\" generated with Ronn/v0.7.3
|
2
|
-
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
3
|
-
.
|
4
|
-
.TH "GIST" "1" "January 2018" "" "Gist manual"
|
5
|
-
.
|
6
|
-
.SH "NAME"
|
7
|
-
\fBgist\fR \- upload code to https://gist\.github\.com
|
8
|
-
.
|
9
|
-
.SH "Synopsis"
|
10
|
-
The gist gem provides a \fBgist\fR command that you can use from your terminal to upload content to https://gist\.github\.com/\.
|
11
|
-
.
|
12
|
-
.SH "Installation"
|
13
|
-
.
|
14
|
-
.IP "\(bu" 4
|
15
|
-
If you have ruby installed:
|
16
|
-
.
|
17
|
-
.IP
|
18
|
-
gem install gist
|
19
|
-
.
|
20
|
-
.IP "\(bu" 4
|
21
|
-
If you\'re using Bundler:
|
22
|
-
.
|
23
|
-
.IP
|
24
|
-
source :rubygems gem \'gist\'
|
25
|
-
.
|
26
|
-
.IP "\(bu" 4
|
27
|
-
For OS X, gist lives in Homebrew
|
28
|
-
.
|
29
|
-
.IP
|
30
|
-
brew install gist
|
31
|
-
.
|
32
|
-
.IP "" 0
|
33
|
-
.
|
34
|
-
.SH "Command"
|
35
|
-
.
|
36
|
-
.IP "\(bu" 4
|
37
|
-
To upload the contents of \fBa\.rb\fR just:
|
38
|
-
.
|
39
|
-
.IP
|
40
|
-
gist a\.rb
|
41
|
-
.
|
42
|
-
.IP "\(bu" 4
|
43
|
-
Upload multiple files:
|
44
|
-
.
|
45
|
-
.IP
|
46
|
-
gist a b c gist *\.rb
|
47
|
-
.
|
48
|
-
.IP "\(bu" 4
|
49
|
-
By default it reads from STDIN, and you can set a filename with \fB\-f\fR\.
|
50
|
-
.
|
51
|
-
.IP
|
52
|
-
gist \-f test\.rb <a\.rb
|
53
|
-
.
|
54
|
-
.IP "\(bu" 4
|
55
|
-
Alternatively, you can just paste from the clipboard:
|
56
|
-
.
|
57
|
-
.IP
|
58
|
-
gist \-P
|
59
|
-
.
|
60
|
-
.IP "\(bu" 4
|
61
|
-
Use \fB\-p\fR to make the gist private:
|
62
|
-
.
|
63
|
-
.IP
|
64
|
-
gist \-p a\.rb
|
65
|
-
.
|
66
|
-
.IP "\(bu" 4
|
67
|
-
Use \fB\-d\fR to add a description:
|
68
|
-
.
|
69
|
-
.IP
|
70
|
-
gist \-d "Random rbx bug" a\.rb
|
71
|
-
.
|
72
|
-
.IP "\(bu" 4
|
73
|
-
You can update existing gists with \fB\-u\fR:
|
74
|
-
.
|
75
|
-
.IP
|
76
|
-
gist \-u GIST_ID FILE_NAME gist \-u 42f2c239d2eb57299408 test\.txt
|
77
|
-
.
|
78
|
-
.IP "\(bu" 4
|
79
|
-
If you\'d like to copy the resulting URL to your clipboard, use \fB\-c\fR\.
|
80
|
-
.
|
81
|
-
.IP
|
82
|
-
gist \-c <a\.rb
|
83
|
-
.
|
84
|
-
.IP "\(bu" 4
|
85
|
-
If you\'d like to copy the resulting embeddable URL to your clipboard, use \fB\-e\fR\.
|
86
|
-
.
|
87
|
-
.IP
|
88
|
-
gist \-e <a\.rb
|
89
|
-
.
|
90
|
-
.IP "\(bu" 4
|
91
|
-
And you can just ask gist to open a browser window directly with \fB\-o\fR\.
|
92
|
-
.
|
93
|
-
.IP
|
94
|
-
gist \-o <a\.rb
|
95
|
-
.
|
96
|
-
.IP "\(bu" 4
|
97
|
-
To list (public gists or all gists for authed user) gists for user
|
98
|
-
.
|
99
|
-
.IP
|
100
|
-
gist \-l : all gists for authed user gist \-l defunkt : list defunkt\'s public gists
|
101
|
-
.
|
102
|
-
.IP "" 0
|
103
|
-
.
|
104
|
-
.P
|
105
|
-
To read a gist and print it to STDOUT
|
106
|
-
.
|
107
|
-
.IP "" 4
|
108
|
-
.
|
109
|
-
.nf
|
110
|
-
|
111
|
-
gist \-r GIST_ID
|
112
|
-
gist \-r 374130
|
113
|
-
.
|
114
|
-
.fi
|
115
|
-
.
|
116
|
-
.IP "" 0
|
117
|
-
.
|
118
|
-
.IP "\(bu" 4
|
119
|
-
See \fBgist \-\-help\fR for more detail\.
|
120
|
-
.
|
121
|
-
.IP "" 0
|
122
|
-
.
|
123
|
-
.SH "Login"
|
124
|
-
If you want to associate your gists with your GitHub account, you need to login with gist\. It doesn\'t store your username and password, it just uses them to get an OAuth2 token (with the "gist" permission)\.
|
125
|
-
.
|
126
|
-
.IP "" 4
|
127
|
-
.
|
128
|
-
.nf
|
129
|
-
|
130
|
-
gist \-\-login
|
131
|
-
Obtaining OAuth2 access_token from github\.
|
132
|
-
GitHub username: ConradIrwin
|
133
|
-
GitHub password:
|
134
|
-
2\-factor auth code:
|
135
|
-
Success! https://github\.com/settings/tokens
|
136
|
-
.
|
137
|
-
.fi
|
138
|
-
.
|
139
|
-
.IP "" 0
|
140
|
-
.
|
141
|
-
.P
|
142
|
-
This token is stored in \fB~/\.gist\fR and used for all future gisting\. If you need to you can revoke it from https://github\.com/settings/tokens, or just delete the file\.
|
143
|
-
.
|
144
|
-
.IP "\(bu" 4
|
145
|
-
After you\'ve done this, you can still upload gists anonymously with \fB\-a\fR\.
|
146
|
-
.
|
147
|
-
.IP
|
148
|
-
gist \-a a\.rb
|
149
|
-
.
|
150
|
-
.IP "" 0
|
151
|
-
.
|
152
|
-
.P
|
153
|
-
If you have a complicated authorization requirement you can manually create a token file by pasting a Github token with only the \fBgist\fR permission into a file called \fB~/\.gist\fR\. You can create one from https://github\.com/settings/tokens
|
154
|
-
.
|
155
|
-
.P
|
156
|
-
This file should contain only the token (~40 hex characters), and to make it easier to edit, can optionally have a final newline (\en or \er\en)\.
|
157
|
-
.
|
158
|
-
.P
|
159
|
-
For example, one way to create this file would be to run:
|
160
|
-
.
|
161
|
-
.IP "" 4
|
162
|
-
.
|
163
|
-
.nf
|
164
|
-
|
165
|
-
echo MY_SECRET_TOKEN > ~/\.gist
|
166
|
-
.
|
167
|
-
.fi
|
168
|
-
.
|
169
|
-
.IP "" 0
|
170
|
-
.
|
171
|
-
.SS "GitHub Enterprise"
|
172
|
-
If you\'d like \fBgist\fR to use your locally installed GitHub Enterprise \fIhttps://enterprise\.github\.com/\fR, you need to export the \fBGITHUB_URL\fR environment variable (usually done in your \fB~/\.bashrc\fR)\.
|
173
|
-
.
|
174
|
-
.IP "" 4
|
175
|
-
.
|
176
|
-
.nf
|
177
|
-
|
178
|
-
export GITHUB_URL=http://github\.internal\.example\.com/
|
179
|
-
.
|
180
|
-
.fi
|
181
|
-
.
|
182
|
-
.IP "" 0
|
183
|
-
.
|
184
|
-
.P
|
185
|
-
Once you\'ve done this and restarted your terminal (or run \fBsource ~/\.bashrc\fR), gist will automatically use github enterprise instead of the public github\.com
|
186
|
-
.
|
187
|
-
.P
|
188
|
-
Your token for GitHub Enterprise will be stored in \fB\.gist\.<protocol>\.<server\.name>[\.<port>]\fR (e\.g\. \fB~/\.gist\.http\.github\.internal\.example\.com\fR for the GITHUB_URL example above) instead of \fB~/\.gist\fR\.
|
189
|
-
.
|
190
|
-
.P
|
191
|
-
If you have multiple servers or use Enterprise and public GitHub often, you can work around this by creating scripts that set the env var and then run \fBgist\fR\. Keep in mind that to use the public GitHub you must unset the env var\. Just setting it to the public URL will not work\. Use \fBunset GITHUB_URL\fR
|
192
|
-
.
|
193
|
-
.SS "Token file format"
|
194
|
-
If you cannot use passwords, as most Enterprise installations do, you can generate the token via the web interface and then simply save the string in the correct file\. Avoid line breaks or you might see: \fB$ gist \-l Error: Bad credentials\fR
|
195
|
-
.
|
196
|
-
.TP
|
197
|
-
You can also use Gist as a library from inside your ruby code:
|
198
|
-
.
|
199
|
-
.IP
|
200
|
-
Gist\.gist("Look\.at(:my => \'awesome\')\.code")
|
201
|
-
.
|
202
|
-
.P
|
203
|
-
If you need more advanced features you can also pass:
|
204
|
-
.
|
205
|
-
.IP "\(bu" 4
|
206
|
-
\fB:access_token\fR to authenticate using OAuth2 (default is `File\.read("~/\.gist"))\.
|
207
|
-
.
|
208
|
-
.IP "\(bu" 4
|
209
|
-
\fB:filename\fR to change the syntax highlighting (default is \fBa\.rb\fR)\.
|
210
|
-
.
|
211
|
-
.IP "\(bu" 4
|
212
|
-
\fB:public\fR if you want your gist to have a guessable url\.
|
213
|
-
.
|
214
|
-
.IP "\(bu" 4
|
215
|
-
\fB:description\fR to add a description to your gist\.
|
216
|
-
.
|
217
|
-
.IP "\(bu" 4
|
218
|
-
\fB:update\fR to update an existing gist (can be a URL or an id)\.
|
219
|
-
.
|
220
|
-
.IP "\(bu" 4
|
221
|
-
\fB:anonymous\fR to submit an anonymous gist (default is false)\.
|
222
|
-
.
|
223
|
-
.IP "\(bu" 4
|
224
|
-
\fB:copy\fR to copy the resulting URL to the clipboard (default is false)\.
|
225
|
-
.
|
226
|
-
.IP "\(bu" 4
|
227
|
-
\fB:open\fR to open the resulting URL in a browser (default is false)\.
|
228
|
-
.
|
229
|
-
.IP "" 0
|
230
|
-
.
|
231
|
-
.P
|
232
|
-
NOTE: The access_token must have the "gist" scope\.
|
233
|
-
.
|
234
|
-
.IP "\(bu" 4
|
235
|
-
If you want to upload multiple files in the same gist, you can:
|
236
|
-
.
|
237
|
-
.IP
|
238
|
-
Gist\.multi_gist("a\.rb" => "Foo\.bar", "a\.py" => "Foo\.bar")
|
239
|
-
.
|
240
|
-
.IP "\(bu" 4
|
241
|
-
If you\'d rather use gist\'s builtin access_token, then you can force the user to obtain one by calling:
|
242
|
-
.
|
243
|
-
.IP
|
244
|
-
Gist\.login!
|
245
|
-
.
|
246
|
-
.IP "\(bu" 4
|
247
|
-
This will take them through the process of obtaining an OAuth2 token, and storing it in \fB~/\.gist\fR, where it can later be read by \fBGist\.gist\fR
|
248
|
-
.
|
249
|
-
.IP "" 0
|
250
|
-
.
|
251
|
-
.SH "Configuration"
|
252
|
-
.
|
253
|
-
.IP "\(bu" 4
|
254
|
-
If you\'d like \fB\-o\fR or \fB\-c\fR to be the default when you use the gist executable, add an alias to your \fB~/\.bashrc\fR (or equivalent)\. For example:
|
255
|
-
.
|
256
|
-
.IP
|
257
|
-
alias gist=\'gist \-c\'
|
258
|
-
.
|
259
|
-
.IP "\(bu" 4
|
260
|
-
If you\'d prefer gist to open a different browser, then you can export the BROWSER environment variable:
|
261
|
-
.
|
262
|
-
.IP
|
263
|
-
export BROWSER=google\-chrome
|
264
|
-
.
|
265
|
-
.IP "" 0
|
266
|
-
.
|
267
|
-
.P
|
268
|
-
If clipboard or browser integration don\'t work on your platform, please file a bug or (more ideally) a pull request\.
|
269
|
-
.
|
270
|
-
.P
|
271
|
-
If you need to use an HTTP proxy to access the internet, export the \fBHTTP_PROXY\fR or \fBhttp_proxy\fR environment variable and gist will use it\.
|
272
|
-
.
|
273
|
-
.SH "Meta\-fu"
|
274
|
-
Thanks to @defunkt and @indirect for writing and maintaining versions 1 through 3\. Thanks to @rking and @ConradIrwin for maintaining version 4\.
|
275
|
-
.
|
276
|
-
.P
|
277
|
-
Licensed under the MIT license\. Bug\-reports, and pull requests are welcome\.
|