Anypaste: Command-line file sharing for hackers.

Anypaste is a tool for uploading files to public-facing hosting sites such as pastebins,, Imgur, and Gfycat. Anypaste automatically detects the type of file being uploaded and chooses an appropriate site accordingly. Anypaste has a plugin system for adding new hosting sites. Anypaste is perfect for sharing content on Reddit, IRC, Discord, Email, forums, or anywhere else that links can go.


The complete guide to installing, using, and making plugins for Anypaste.

IntroductionBack to Top

Anypaste is a tool for uploading files to public-facing websites. Ideally, you can run anypaste /path/to/file and several things will happen:

  1. Anypaste will use file and other utilities to determine the type of the file.
  2. Anypaste will filter the list of plugins (supported hosting sites) to the ones which report they are compatible with the file.
  3. Anypaste will pass control to the “best” supported plugin, which will upload the file to the site and send the link to your terminal.

Anypaste is written in Bash, and was designed to support Linux and macOS. It should also work on other *nix-y systems, like FreeBSD or the Windows Subsystem for Linux, but some desktop integration features (namely the --copy and --notify command line parameters) will probably have issues.

InstallationBack to Top

Anypaste is just a single, cross-platform executable! That’s because it’s a shell script. You can download it from, which will just redirect you to the raw file hosted on GitHub.

Quick installation:

sudo mkdir -p /usr/local/bin # only needed on macOS
sudo curl -Lo /usr/local/bin/anypaste
sudo chmod +x /usr/local/bin/anypaste


Bash, curl, and POSIX core utils are all you need. ffprobe is optional but can provide more accurate compatibility checking for media file types; typically it comes inside of an ffmpeg package.

Command-line optionsBack to Top

All command-line options are documented in anypaste -h as well as here.

ConfigurationBack to Top

Anypaste’s configuration file is a small shell script which sets environment variables. As such, if you know how to write Bash, you know how to write Anypaste config. Here’s a cheat sheet:

The export preceding variable names tells Bash to pass these variables to subprocesses. The export is only necessary when configuring external plugins, i.e plugins that aren’t built-in to Anypaste.

To create your configuration file, run anypaste -C. It will tell you where the config file was put. It will typically be ~/.config/anypaste.conf on Linux and ~/.anypaste.conf on Mac. Everything is commented out by default.

Option Description Default
ap_plugins List of enabled plugins, in order of precedence See config file
ap_hooks List of hooks that are enabled by default Empty
ap_hook_policy If set to “greedy”, hooks will be run after every file uploaded. If set to “lazy”, they will only be run just before Anypaste exits. lazy
ap_unicode Whether to prettify things with unicode characters. Mainly used in anypaste -l. true
ap_color Whether to colorize the output. true
ap_copy_regex The regular expression to determine which line to copy from when --copy is used. . (matches first line)
ap_ua User-agent to use Anypaste 1.15 (or other version)

Post-Upload HooksBack to Top

Hooks run after Anypaste finishes uploading a file. Anypaste has two built-in hooks:

You can change how hooks work when multiple files are uploaded using ap_hook_policy. If it is set to lazy (the default), hooks will only run after the last file in a batch. If set to greedy, they will be run after every file.

Custom hooks can be added to the ap_hooks array in the config file. They have access to the same environment variables as plugins, but additionally can see the output of the last plugin in ap_last_stdout. Custom hooks are able to work in combination with built-in plugins; both will run. Example: Adding the following to your config file will save every link uploaded with Anypaste to ~/Other/anypaste-links.txt:

ap_hooks=('echo -n "$ap_last_stdout" | grep ^Link: | head -n 1 >> ~/Other/anypaste-links.txt')

PluginsBack to Top

Anypaste plugins are each single executable files (except for the built-in ones, which are bundled inside the main Anypaste executable). The recommended way to “install” a plugin is to download it from its author’s website (hopefully a GitHub release), mark it as executable (chmod +x plugin-file), then put it in ~/.anypaste-plugins (you may need to create this folder). Alternatively, you could put it anywhere in your $PATH. After that, you must enable the plugin by adding it to the ap_plugins array in your config file. Remember that this array is in order of precedence – if you put it at the end, it will almost never be used!

We are always looking for more plugins. If you know a good hosting site that’s been around for at least three years, open a Github issue and I will consider adding it!

Built-In Plugins

Note that plugins sometimes break when the site is updated. I occasionally check the plugins and update them. However, this means that the Anypaste version listed in the table may not actually work – make sure to update Anypaste before reporting any issues!

Name File Types Extra Notes Anypaste version
Sendvid Videos 1.0
Streamable Videos Requires authentication. 1.0
Gfycat Videos (Gifs) Short videos only. 1.0
Imgur Images Uses a hardcoded API key. 1.1
Pixhost Images 10MB upload limit. 1.1.4 Text 1.0
Pastie Text 1.1.4 Text 1.1.4
Paste2 Text 1.1.4
Hastebin Text Frequent downtimes. 1.0
Docdroid Documents Requires authentication. 1.0
Gofile Generic Unlimited size, official API. 1.1.4
Bayfiles Generic 20GB limit, Official API. 1.1.4
Filemail Generic 50GB upload limit. 1.1.3 Generic 10GB upload limit. 1.1 Generic 500MB upload limit. 1.1.3 Generic Files deleted after first download. 1.0

Third party plugins

Want to see your plugin on this list? Open an issue!

Name Description Plugin Homepage
ThinImg A simple plugin created mainly to serve as an example about how to make third-party plugins. Note that has gone down since this plugin was created, so it is useful only for pedagogical purposes. See Making Plugins for more information. GitHub

Making PluginsBack to Top

An Anypaste plugin is just an executable file (Bash will be used for all examples, but you can use any language you wish). This executable file is called with a single argument, which instructs the plugin on what to do. Additional data is not passed on the command line, but rather supplied through environment variables which the plugin can read at will. Here’s a list of “commands” (the command line arguments) that can be passed to your plugin, and what your plugin should do in each situation:


The plugin should determine whether the file being uploaded is compatible with this plugin. Typically, this involves checking that $ap_mime is a supported MIME type and that $ap_size is not over the site’s size limit. The plugin should exit with an exit code of 0 if it’s compatible, or non-zero if it is incompatible. This step should not involve any sort of network communications.


The plugin should perform the actual upload. Typically this involves using curl to upload the file at $ap_path, using whatever API the site provides. It might also use $ap_human_name to set the name of the file on the site being uploaded to, if the site supports that. Any warnings, errors, or progress bars should be outputted to stderr. If the upload completes successfully, the plugin should output a blank line to stdout, followed by the links, followed by another blank line. Each “link” should consist of some sort of label, followed by :, then followed by the actual link. Here’s an example output:


Your plugin should try to use “standard” names before the : whenever possible. This makes Anypaste’s behavior more consistent, and makes it easier to use inside of other scripts. If there’s something special about a link that a user should know, it’s better to output it to stderr before the links rather than stdout with the links. When in doubt, look at the built-in plugins and try to act as similarly to them as possible.

Exit with a code of 0 if the upload was successful, or non-zero otherwise.


The plugin should output “static” information about itself (metadata). Most of the environment variables will not be available during this step. Your plugin should output its information in an ini-like format. Each “section” should start with [section-name], then any lines after that until the next section are the contents. Blank lines are ignored. For example:

This is a cool plugin for uploading to
required|imgur_api_public|Public API key
requied|imgur_api_secret|Private API secret

List of possible sections:

Aside: Config options

Config options are just environment variables which are set in the config file. You don’t have to do anything special to get access to them. Keep in mind that they are in a “global” scope, so name them in a way that they don’t interfere with other config options (e.g, don’t name an option “api_key”; instead, use “imgur_api_key”)

Example plugins

The official example plugin for ThinImg is a great learning resource. However, ThinImg is very simple, and we don’t make use of some of the features plugins can have. If you want to see more fleshed-out plugins, look in the first several hundred lines of the main Anypaste source code – that’s where all the built-in plugins are.

Environment VariablesBack to Top

Plugins and hooks have access to a number of environment variables. This is the primary way to get information about the currently uploading file.

Variable Description
ap_path The absolute path to the uploading file on-disk.
ap_human_name The name specified using -n or inferred from the file name.
ap_file_info Output of file "$ap_path", contains lots of useful file metadata.
ap_mime Mime type of the file (from file --mime-type --brief "$ap_path").
ap_ffprobe Output of ffprobe -show_streams -show_format "$ap_path". Null if ffprobe is not installed. Often provides more accurate and reliable info that file can for audio and video.
ap_size Size of the file, in bytes (from wc -c).
ap_plugin The name of the plugin as it appears in ap_plugins.
ap_version Current Anypaste version.
ap_mac true if running on Mac, false otherwise.

There are many other variables set by Anypaste, but they are meant for internal use only and may change without warning.