Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/defunkt/gist
Potentially the best command line gister.
https://github.com/defunkt/gist
Last synced: 4 days ago
JSON representation
Potentially the best command line gister.
- Host: GitHub
- URL: https://github.com/defunkt/gist
- Owner: defunkt
- License: mit
- Created: 2008-10-10T23:35:47.000Z (about 16 years ago)
- Default Branch: master
- Last Pushed: 2022-06-23T18:02:22.000Z (over 2 years ago)
- Last Synced: 2024-12-14T01:34:14.557Z (8 days ago)
- Language: Ruby
- Homepage: http://defunkt.io/gist/
- Size: 1.33 MB
- Stars: 3,806
- Watchers: 61
- Forks: 341
- Open Issues: 61
-
Metadata Files:
- Readme: README.md
- License: LICENSE.MIT
Awesome Lists containing this project
- awesomeness - gist - The gist gem provides a gist command that you can use from your terminal to upload content to GitHub. (GitShit)
README
gist(1) -- upload code to https://gist.github.com
=================================================## Synopsis
The gist gem provides a `gist` command that you can use from your terminal to
upload content to https://gist.github.com/.## Installation
If you have ruby installed:
gem install gist
If you're using Bundler:
source :rubygems
gem 'gist'For OS X, gist lives in Homebrew
brew install gist
For FreeBSD, gist lives in ports
pkg install gist
<200c>For Ubuntu/Debian
apt install gist
Note: Debian renames the binary to `gist-paste` to avoid a name conflict.
## Command
To upload the contents of `a.rb` just:
gist a.rb
Upload multiple files:
gist a b c
gist *.rbBy default it reads from STDIN, and you can set a filename with `-f`.
gist -f test.rb ~/.gist)
The `umask` ensures that the file is only accessible from your user account.
### GitHub Enterprise
If you'd like `gist` to use your locally installed [GitHub Enterprise](https://enterprise.github.com/),
you need to export the `GITHUB_URL` environment variable (usually done in your `~/.bashrc`).export GITHUB_URL=http://github.internal.example.com/
Once you've done this and restarted your terminal (or run `source ~/.bashrc`), gist will
automatically use GitHub Enterprise instead of the public github.comYour token for GitHub Enterprise will be stored in `.gist..[.]` (e.g.
`~/.gist.http.github.internal.example.com` for the GITHUB_URL example above) instead of `~/.gist`.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 `gist`. 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 `unset GITHUB_URL`### Token file format
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:
```
$ gist -l
Error: Bad credentials
```# Library
You can also use Gist as a library from inside your ruby code:
Gist.gist("Look.at(:my => 'awesome').code")
If you need more advanced features you can also pass:
* `:access_token` to authenticate using OAuth2 (default is `File.read("~/.gist")).
* `:filename` to change the syntax highlighting (default is `a.rb`).
* `:public` if you want your gist to have a guessable url.
* `:description` to add a description to your gist.
* `:update` to update an existing gist (can be a URL or an id).
* `:copy` to copy the resulting URL to the clipboard (default is false).
* `:open` to open the resulting URL in a browser (default is false).NOTE: The access_token must have the `gist` scope and may also require the `user:email` scope.
If you want to upload multiple files in the same gist, you can:
Gist.multi_gist("a.rb" => "Foo.bar", "a.py" => "Foo.bar")
If you'd rather use gist's builtin access_token, then you can force the user
to obtain one by calling:Gist.login!
This will take them through the process of obtaining an OAuth2 token, and storing it
in `~/.gist`, where it can later be read by `Gist.gist`## Configuration
If you'd like `-o` or `-c` to be the default when you use the gist executable, add an
alias to your `~/.bashrc` (or equivalent). For example:alias gist='gist -c'
If you'd prefer gist to open a different browser, then you can export the BROWSER
environment variable:export BROWSER=google-chrome
If clipboard or browser integration don't work on your platform, please file a bug or
(more ideally) a pull request.If you need to use an HTTP proxy to access the internet, export the `HTTP_PROXY` or
`http_proxy` environment variable and gist will use it.## Meta-fu
Thanks to @defunkt and @indirect for writing and maintaining versions 1 through 3.
Thanks to @rking and @ConradIrwin for maintaining version 4.Licensed under the MIT license. Bug-reports, and pull requests are welcome.