From Gentoo Wiki
Jump to:navigation Jump to:search

wgetpaste is a command-line tool for posting snippets of text to various online "pastebin" services. It makes it easy to post text to a pastebin, and presents a link for sharing the post. It should be very useful for providing information to help with troubleshooting, for posting to IRC or to the forums, for example.

See the service selection section for a list of available pastebin services. Visit a service's website for usage-information specific to that service.

The default service, dpaste.com, is well suited for posting to Gentoo IRC or requesting support. Services that require javascript to view the posts can be impractical.

Remember that paste services are often public, avoid posting sensitive information. It may not be possible to delete posted information.


USE flags

wgetpaste currently has just one use flag, for using SSL/TLS or not:

USE flags for app-text/wgetpaste Command-line interface to various pastebins

ssl Add support for SSL/TLS connections (Secure Socket Layer / Transport Layer Security)


Install app-text/wgetpaste:

root #emerge --ask app-text/wgetpaste


Settings, notably the default service, can be configured globally in /etc/wgetpaste.conf or in /etc/wgetpaste.d/*.conf, or per-user in ~/.wgetpaste.conf or in ~/.wgetpaste.d/*.conf.

There is an example configuration file available.

Github gists

The gists service requires a valid API token. Generate it on the Github website and paste it into a config snippet:

FILE ~/.wgetpaste.d/gists.conf
HEADER_gists="Authorization: token abcdef..."

A gist must be set to public or private by setting the PUBLIC_gists variable either in the config file, or on the command-line, thus (for Bash):

user $PUBLIC_gists=false wgetpaste -s gists <path-to-file>

PUBLIC_gists must be set to true or false only or it will report an error!



Invoke wgetpaste with the --help option for useful information on usage:

user $wgetpaste --help
Usage: /usr/bin/wgetpaste [options] [file[s]]

    -l, --language LANG           set language (defaults to "Plain Text")
    -d, --description DESCRIPTION set description (defaults to "stdin" or filename)
    -n, --nick NICK               set nick (defaults to your username)
    -s, --service SERVICE         set service to use (defaults to "dpaste")
    -e, --expiration EXPIRATION   set when it should expire (defaults to "1")

    -S, --list-services           list supported pastebin services
    -L, --list-languages          list languages supported by the specified service
    -E, --list-expiration         list expiration setting supported by the specified service

    -u, --tinyurl URL             convert input url to tinyurl

    -c, --command COMMAND         paste COMMAND and the output of COMMAND
    -i, --info                    append the output of `emerge --info`
    -I, --info-only               paste the output of `emerge --info` only
    -x, --xcut                    read input from clipboard (requires x11-misc/xclip)
    -X, --xpaste                  write resulting url to the X primary selection buffer (requires x11-misc/xclip)
    -C, --xclippaste              write resulting url to the X clipboard selection buffer (requires x11-misc/xclip)

    -r, --raw                     show url for the raw paste (no syntax highlighting or html)
    -t, --tee                     use tee to show what is being pasted
    -v, --verbose                 show wget stderr output if no url is received
        --completions             emit output suitable for shell completions (only affects --list-*)
        --debug                   be *very* verbose (implies -v)

    -h, --help                    show this help
    -g, --ignore-configs          ignore ""/etc/wgetpaste.conf, ~/.wgetpaste.conf etc.
        --version                 show version information

can be overridden globally in ""/etc/wgetpaste.conf or ""/etc/wgetpaste.d/*.conf or
per user in any of ~/.wgetpaste.conf or ~/.wgetpaste.d/*.conf.

An additional http header can be passed by setting HEADER_${SERVICE} in any of the
configuration files mentioned above. For example, authenticating with github gist:
HEADER_gists="Authorization: token 1234abc56789...", or with gitlab snippets:
HEADER_snippets="PRIVATE-TOKEN: 1234abc56789..."

You can also set PUBLIC_gists='false' if you want to default to secret instead of
public github gists. In the case of gitlab, you can set VISIBILITY_snippets= to
'public', 'private' or 'internal'"

To change your gitlab server, you can override the default API URL setting

Service selection

Before posting a snippet, care should be taken to select the desired service to post to.

To show which is the current default service, and list available services, use the --list-services (-S for short) option:

user $wgetpaste --list-services
Services supported: (case sensitive):
   Name:     | Url:
    0x0      | http://0x0.st
    bpaste   | https://bpaste.net/
    codepad  | http://codepad.org/
   *dpaste   | http://dpaste.com/api/v2/
    gists    | https://api.github.com/gists
    ix_io    | http://ix.io
    snippets | https://gitlab.com/api/v4/snippets
    sprunge  | http://sprunge.us

The default service is marked with an asterisk, this service will be used unless a different service is selected with the --service (-s for short) option, when pasting. For example:

user $wgetpaste --service codepad file.txt

Different paste services have different constraints, such as allowable size, retention period etc. Go to the service website for full information. For larger posts, 0x0 may be useful.

It may be preferable to simply set a sensible default service before use, or just leave it as "dpaste" - see the configuration section.

Posting a file

To post a file, simply run wgetpaste followed by the filename, not forgetting to specify a paste service if somthing other than the default is required.

For example, run the following command to create a paste of the system's Xorg configuration:

user $wgetpaste /etc/X11/xorg.conf

To create a paste of xorg.conf using the tiny URL service use the --tinyurl option (-u for short):

user $wgetpaste --tinyurl /etc/X11/xorg.conf

Post command output

A command's output may be directly posted to a snippet service, though it is recommended to write output to a file and check the contents before pasting, to avoid any possible security issues.

To paste the entire output of a command, use the --command (-c for short) option. Remember to quote the command:

user $wgetpaste --command 'emerge -vp musique'

Content may also be piped to wgetpaste, though this may omit stderr, so "2>&1" can be used, for example.

Advanced options

To set a language for syntax highlighting use the --language (-l for short) option:

user $wgetpaste --language Bash /etc/bash/bashrc

Use the --list-languages (-L for short) option to list all available languages, these depend on the selected paste service:

user $wgetpaste --list-languages
See the invocation section for other advanced options, such as automatically adding system diagnostic information, or pasting to or from clipboards.

External references