Soft / weechat-share-file

Weechat-share-file is an extension for popular WeeChat IRC-client that makes sharing files blazingly fast.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dashing file sharing for WeeChat 🚀

Weechat-share-file is an extension for popular WeeChat IRC-client that makes sharing files blazingly fast. No longer will there be a disparity between newfangled IM clients and the trusty old IRC when it comes to the ease of sharing photos and files. Just pick a file and WeeChat will share it using the sharing service of your choice and provide you with an URL ready to be sent out. All without leaving the comfort of your chat buffer.

The script adds an integrated file browser to WeeChat that allows users to select the files they wish to share. How the files are actually shared is dependent upon their type and can be configured using a built-in command. Adding an external sharing tool simply requires associating it with a MIME type.

The aesthetics of weechat-share-file have been strongly influenced by Emacs' Ido-mode and the ever so useful go.py buffer selection tool.

Features

  • Snappy, search-oriented interface
  • Multiple matching methods
  • Sorting
  • …and more!

Installation

weechat-share-file requires WeeChat compiled with a support for Python 2.7 and python-magic package to be installed.

At present, weechat-share-file can only be installed directly from this repository. Simply download the share_file.py script to WeeChat's python script directory:

cd ~/.weechat/python # or alternatively ~/.weechat/python/autoload if you wish the script to be automatically loaded on start up
wget https://bitbucket.org/Soft/weechat-share-file/raw/master/share_file.py

After this, the script is ready to be activated:

/python load share_file.py

It is also recommended to bind the /share command to a key combination.

/key bind meta-o /share

Binds the /share command to ALT-o.

Viewing and Editing Program Associations

weechat-share-file relies on external programs for sharing the files. This means it is not dependent on any particular service and that adding support for new services is close to trivial. However, this decoupling also means that there is some configuration required, before the script can be fully utilized. The sharers directory contains a few example scripts for uploading files to popular hosting services.

weechat-share-file chooses how a file should be shared based on its MIME type. Applications can be associated with MIME type patterns. For example, by default the script has just a single association:

/sharers list

All sharers:
  1. * echo

This means that any type of file (the * pattern in the output) is "shared" using the echo command. This causes the path to the selected file to be appended to the message, when the user tries to share a file. We can add a new associating for files of type image/*:

/sharers add image/* imgur.sh 1

This assumes that a script imgur.sh resides in the PATH. The final 1 in the command specifies the rule's priority. The rules are tried sequentially until a matching rule is found. Since the default rule matches all the files we added the new rule with a higher priority. Now, if we take a look at the associations listing we'll see:

All sharers:
  1. image/* imgur.sh
  2. *       echo

This means that if the file is an image, it is shared via the imgur.sh script. If the file is not an image, it is still sent to echo. If we want to, we can now delete the default rule by executing:

/sharers del 2

Usage

Once setup, you should be able to invoke /share command on any buffer by pressing ALT-o. The command transforms the input bar into an inline file browser that can then be used to select files for sharing. The browser should support everything you would expect from any self-respecting file explorer utility. As a search-oriented interface, the listing can be further filtered down by searching. By default, ALT-TAB and ALT-SHIFT-TAB can be used to move between the candidates.

Additional Configuration

weechat-share-file supports a bunch of customization options. Available options can be viewed with /set plugins.var.python.share_file.*.

License

weechat-share-file and all the associated scripts are licensed under the GNU General Public License Version 3 or any later version.

About

Weechat-share-file is an extension for popular WeeChat IRC-client that makes sharing files blazingly fast.


Languages

Language:Python 88.9%Language:Shell 11.1%