Anypaste is a command line pastebin tool that’s not just for plain text. Anypaste supports dozens of hosting sites that accept a variety of different file types, such as images, audio, and video, and has a plugin system to add your favorite hosting site if you find it’s missing. Anypaste is great for sharing content via Reddit, IRC, Discord, Email, forums, or anywhere else that links can go.

Introduction Back 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: Anypaste will use file and other utilities to determine the type of the file. Anypaste will filter the list of plugins (supported hosting sites) to the ones which report they are compatible with the file. 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 a tool for uploading files to public-facing websites. Ideally, you can runand several things will happen: 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.

Installation Back to Top Anypaste is just a single, cross-platform executable! That’s because it’s a shell script. You can download it from Anypaste is just a single, cross-platform executable! That’s because it’s a shell script. You can download it from https://anypaste.xyz/sh , 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 https://anypaste.xyz/sh sudo chmod +x /usr/local/bin/anypaste Dependencies 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 options Back to Top All command-line options are documented in anypaste -h as well as here. -p : Specify part of a plugin name to use.

: Specify part of a plugin name to use. -t : Comma-separated list of required tags. For example, -t private,permanent will only match plugins that keep your file indefinitely and don’t publicly list links.

: Comma-separated list of required tags. For example, will only match plugins that keep your file indefinitely and don’t publicly list links. -f : Skip compatibility checks (force).

: Skip compatibility checks (force). -i : Interactive mode. Check it out, super cool!

: Interactive mode. Check it out, super cool! -n : Specify a custom name for the file (displayed only on certain sites).

: Specify a custom name for the file (displayed only on certain sites). -c : Specify a path to a custom configuration file.

: Specify a path to a custom configuration file. -C : Create a default configuration file. Everything will be commented out by default. See Configuration for more info.

: Create a default configuration file. Everything will be commented out by default. See Configuration for more info. -l , --list : List all currently installed plugins in human-readable form. Can be combined with other options, if so it will list the plugins that would otherwise be attempted for upload.

, : List all currently installed plugins in human-readable form. Can be combined with other options, if so it will list the plugins that would otherwise be attempted for upload. --list-machine : Same as -l , but for use inside of other scripts. It prints the raw get_info output from each plugin, with a blank line between plugins and at the end.

: Same as , but for use inside of other scripts. It prints the raw output from each plugin, with a blank line between plugins and at the end. -x , --copy , --notify : See Post-Upload Hooks.

, , : See Post-Upload Hooks. -v , --version : Print version.

, : Print version. -h , --help : Print help text. All command-line options are documented inas well as here.

Configuration Back 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: Set variable (string): export var_name='I am a string' .

. Set variable (number): export var_name=647 .

. Set array: export arr_name=('I am a string' 42 'This is the third element') .

. Comment: # don't unset this or everything will break! Not sure why... . 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)

Post-Upload Hooks Back to Top Hooks run after Anypaste finishes uploading a file. Anypaste has two built-in hooks: Copy: Copies the link to your clipboard. Activated by adding the -x or --copy command-line options. By default it copies the “main” link, i.e. the one that begins with Link: . If you wish to copy a different link, say the “direct” links, you can set the ap_copy_regex config option to the regex pattern which will match the line containing the link you want. For direct links, you can do export ap_copy_regex=Direct .

or command-line options. By default it copies the “main” link, i.e. the one that begins with . If you wish to copy a different link, say the “direct” links, you can set the config option to the regex pattern which will match the line containing the link you want. For direct links, you can do . Notify: Sends a desktop notification when an upload completes. Activated with --notify . It uses notify-send on Linux to achieve a cross-desktop-environment experience, but some distros may not ship with it. On Mac, it should “just work” out of the box. 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_hook_policy=greedy ap_hooks=('echo -n "$ap_last_stdout" | grep ^Link: | head -n 1 >> ~/Other/anypaste-links.txt')

Plugins Back 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 Built-In Plugins 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 Tinyimg Images 1.0 Imgur Images Uses a hardcoded API key. 1.1 Clyp Audio Pretty crappy. 1.1 Hastebin Text Has frequent downtimes. 1.0 ix.io Text 1.0 Docdroid Documents Requires authentication. 1.0 Filemail Generic 50GB upload limit (no authentication). 1.1.3 Transfer.sh Generic 10GB upload limit (no authentication). 1.1 Dmca.gripe Generic 1GB upload limit. 1.1 File.io Generic Files deleted after first download. 1.0 Third party plugins 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 (), then put it in(you may need to create this folder). Alternatively, you could put it anywhere in your. After that, you must enable the plugin by adding it to thearray 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! Want to see your plugin on this list? Open an issue! Name Description Plugin Homepage ThigImg A simple plugin created mainly to serve as an example about how to make third-party plugins. See Making Plugins for more information. GitHub

Making Plugins Back 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: check_eligibility 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. upload 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: Link: https://imgur.com/abcdef Direct: https://i.imgur.com/abcdef.png Edit: https://imgur.com/edit/abcdef/secret Delete: https://imgur.com/delete/abcdef/secret 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. get_info 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: [description] This is a cool plugin for uploading to imgur.com [tags] permanent editable deletable [config] required|imgur_api_public|Public API key requied|imgur_api_secret|Private API secret List of possible sections: name : A human-readable name of the plugin. Often just a capitalized version of the machine-readable name.

: A human-readable name of the plugin. Often just a capitalized version of the machine-readable name. description : A human-readable description of what this plugin does.

: A human-readable description of what this plugin does. tags : The plugin’s tags, line-separated.

: The plugin’s tags, line-separated. config : Has lines in the format requiredness|name|description . Each is an additional environment variable/configuration option that the user may supply via anypaste.conf . requiredness should be either optional , in which case it is purely cosmetic for display in anypaste -l , recommended , which will trigger a warning whenever the plugin is run without that option, and required , which will consider the plugin incompatible if that option is missing. name is the name of the environment variable for this option. description is cosmetic and human-readable. 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.