Kate-Get

Kate-Get takes a space separated list of file paths and checks each one against a list of sources. If a match is found, the file is copied via rsync to a local directory. Options for each source are controlled by a config file. Subdirectories are handled automatically based on how local and remote root paths are set.

Usage

First, make a config file for kate-get (see the next section) and then call it with

kate-get "file_1 file_2 file_3"

The quoted argument is a space separated string of full file paths. Each file will be checked against the list of sources until it matches one, then the file will be copied into the corresponding subdirectory of the root directory for that source.

YARD documentation can be found at the RubyGems.org page rubygems.org/gems/kate-get.

Making a config file

By default, Kate-Get looks for the YAML file

~/.kate-get.yml

An example of a config file

:global:
  :host: "example.com"
  :port: 22
  :user: "user-name"

:sources:
  "foo.com":
    :local: "~/Development/foo"
    :root: "/var/www/vhosts/##source_name##/htdocs"
    :base: "sftp://[email protected]:22/var/www/vhosts/##source_name##/htdocs/"
  "bar.com":
    :local: "~/Development/bar"
    :root: "/var/www/vhosts/##source_name##/htdocs"
    :base: "sftp://[email protected]:22/var/www/vhosts/##source_name##/htdocs/"
    :host: "bar.com"
    :port: 42
    :user: "bar-user-name"

There are two sections

  • global - rsync connection information

    • host - hostname or IP

    • port - port to connect on

    • user - username to connect with

    • These options may be overridden on a per-source basis by specifying them there.

  • sources - each entry is a source name (string) with the following options

    • local - path to local folder where files should be copied too (no leading slash)

    • root - path to remote folder (input file must exist in some subdirectory of this to be copied)

    • base - prefix string that will be stripped from the file name

Note that the string ##source_name## will be automatically replaced by the source name.

In this example config, there are two sources named foo.com and bar.com. Here, bar.com has been configured to use different connection info. If a file path starts with the base of one of these sources, it will be copied to the corresponding subdirectory of the root directory for that source. For example, if file_1 was

sftp://[email protected]:22/var/www/vhosts/foo.com/htdocs/css/style.css

rsync would copy the remote file from example.com

/var/www/vhosts/foo.com/htdocs/css/style.css

to the local file

~/Development/foo/css/style.css

This configuration uses a base which is the form Kate uses when accessing a file over sftp.

Setting up Kate to use Kate-Get

Kate-Get is meant to be used with Kate (kate-editor.org) as an external tool. For information on adding external tools to Kate see docs.kde.org/stable/en/kdesdk/kate/config-dialog.html.

If you want a tool that only copies the currently open file use

kate-get "%URL"

If you want to loop through all open files use

kate-get "%URLs"

Note that you may need to use the full path to the kate-get binary, usually

/var/lib/gems/1.9.1/bin/kate-get

The example confiuration given above

Installation

Gem Installation

Download and install Kate-Get with

gem install kate-get

Development

Source Repository

Kate-Get is currently hosted at github. The github web page is github.com/razor-x/kate-get. To clone the project run

git clone git://github.com/razor-x/kate-get.git

License

Kate-Get is licensed under the MIT license.

Warranty

This software is provided “as is” and without any express or implied warranties, including, without limitation, the implied warranties of merchantibility and fitness for a particular purpose.