Skip to main content

Like GNU cat, but with autocompletion for S3.

Project description

https://raw.githubusercontent.com/mpenkov/koshka/master/matroskin.jpeg

Usage

Autocompleting S3 bucket names:

$ kot s3://my{tab}
//mybucket      //mybucket1     //mybucket2

Autocompleting S3 prefixes:

$ kot s3://mybucket/myf{tab}
//mybucket/myfile0.txt      //mybucket/myfile0.json

Autocompleting S3 output prefixes:

$ kot README.rst -o //mybucket/myf{tab}
//mybucket/myfile0.txt      //mybucket/myfile0.json

Editing a remote file transparently (again, with autocompletion):

$ kote //mybucket/myfile0.txt{enter}
{$EDITOR opens a copy of the file locally}
{Once $EDITOR exits, the local file overwrites the remote destination}

Aliasing:

$ kot data/README.md{tab}
https://mydataserver.developers.mycompany.com/README.md

Use this for long-ish URLs that you access frequently. See the configuration section below for alias settings.

Why?

The project initially focused on S3, but then expanded to HTTP/S as well.

The existing awscli tool does not support autocompletion. If you don’t know the exact key, you need to look it up first, using an additional command:

$ aws s3 ls s3://bucket/
2018-07-12 20:22:15        575 key.yaml
$ aws s3 cp s3://bucket/key.yaml -
...

If the key is long, you still need to type it all in:

$ aws s3 ls s3://thesimpsons/apu
2018-07-12 20:22:15     123456 apu_nahasapeemapetilon.png
$ aws s3 cp s3://thesimpsons/apu_nahasapeemapetilon.png -
...

Another problem is dealing with non-standard endpoints, like localstack. You need to specify the endpoint URL for each command, e.g.:

$ aws --endpoint-url https://localhost:4566 s3 cp s3://local/hello.txt -
hello world!

If you’re lazy, and access S3 via the CLI often, then the above problems are a pain point. kot solves them with autocompletion and an optional configuration file:

$ kot s3://bucket/{tab}
//key.yaml
$ kot s3://thesimpsons/apu{tab}
//apu_nahasapeemapetilon.png
$ kot s3://local/hello{tab}
//hello.txt
{enter}
hello world!

Installation

To install the latest version from PyPI:

pip install koshka

To get autocompletion to work under bash:

pip install argcomplete
eval "$(kot --register)"
eval "$(kote --register)"

See argcomplete documentation for information about other platforms.

Configuration (optional)

You may tell kot which AWS profile and/or endpoint URL to use for its requests via a config file. Put the config file in $HOME/kot.cfg. An example:

[s3://mybucket]
endpoint_url = http://localhost:4566

[s3://myotherbucket]
profile_name = myprofile

[https://mydataserver.developers.mycompany.com/README.md]
alias = data

The section names are interpreted as regular expressions. So, in the above example, kot will use http://localhost:4566 as the endpoint URL for handle all requests starting with s3://mybucket. Similarly, it will use the myprofile AWS profile to handle all requests starting with s3://myotherbucket.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

koshka-0.4.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

koshka-0.4-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file koshka-0.4.tar.gz.

File metadata

  • Download URL: koshka-0.4.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for koshka-0.4.tar.gz
Algorithm Hash digest
SHA256 82e3cd3dcaec50ecceda5b0c4c0c49fdc9e6e85fa1311d251606dae8fba90408
MD5 a3cc8aadb768bb7a581c6f0184d68bb1
BLAKE2b-256 968cfbeb726396b078cca0e6ed335efb81013a6ab3f72632f99fae8477c39b46

See more details on using hashes here.

File details

Details for the file koshka-0.4-py3-none-any.whl.

File metadata

  • Download URL: koshka-0.4-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for koshka-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 cfb4a9c3c01f1401338a25361b13013433eddd6f84d27ae896128b49b253842b
MD5 9146f5b713cc3d396b2431ddd340dbbe
BLAKE2b-256 dba801ba84524d27f5f8b1e083f02c813dc12ab363ae3a52e6c2b8f327296802

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page