Skip to main content

Path to action.

Project description

When you click to a file or folder in graphical OS they will be opened in associated app. The xontrib-onepath brings the same logic for the xonsh shell. Type the filename or path without preceding command and an associated action will be executed. The actions are customizable.

If you like the idea of bar theme click ⭐ on the repo and stay tuned by watching releases.

Install

xpip install -U xontrib-onepath
echo 'xontrib load onepath' >> ~/.xonshrc
# Reload xonsh

Default actions

File type Action
inode/directory ls
text/plain vim
image/png xdg-open

Help to add more types and best default actions. PRs are welcome!

Customize actions

Use XONTRIB_ONEPATH_ACTIONS environment variable to add new actions:

$XONTRIB_ONEPATH_ACTIONS['.xonshrc'] = 'vim'         # vim for `.xonshrc` file
$XONTRIB_ONEPATH_ACTIONS['*.log'] = 'tail'           # tail for text type *.log files
$XONTRIB_ONEPATH_ACTIONS['text/plain.txt'] = 'less'  # less for plain text *.txt files 
$XONTRIB_ONEPATH_ACTIONS['inode/directory'] = 'cd'   # the same as xonsh $AUTO_CD=True
$XONTRIB_ONEPATH_ACTIONS['application/zip'] = 'als'  # list files in zip file using atool

To get file type for new file run file --mime-type --brief <file>.

Complex actions

If you need more complex actions use callable xonsh aliases:

import pandas as pd
def _view_csv_with_pandas(args):
    print(pd.read_csv(args[0]))

aliases['view_csv_with_pandas'] = _view_csv_with_pandas
del _view_csv_with_pandas

$XONTRIB_ONEPATH_ACTIONS['application/csv'] = 'view_csv_with_pandas'

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

xontrib-onepath-0.0.1.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

xontrib_onepath-0.0.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file xontrib-onepath-0.0.1.tar.gz.

File metadata

  • Download URL: xontrib-onepath-0.0.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5

File hashes

Hashes for xontrib-onepath-0.0.1.tar.gz
Algorithm Hash digest
SHA256 8384b2ff038b1e78b45e92e1ba3c9d0437a6fb2863396691c3db63fc9d869896
MD5 bbbca2c307cfdbfcb22850803f4ef728
BLAKE2b-256 3c3013a1b0b321e3b838682abfd7c859debd529cc75cae781821e53605310dc9

See more details on using hashes here.

File details

Details for the file xontrib_onepath-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: xontrib_onepath-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5

File hashes

Hashes for xontrib_onepath-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ece8f2b2abff25546d3d0b4848edeb28d3f0354f2ef2f0da023ac8b601822d43
MD5 e644b038da76bc55268245e2fb4cdebb
BLAKE2b-256 ce86ae6c89957d428f1d6c29027fef75e9d0110882370dda5abebde9897d2309

See more details on using hashes here.

Supported by

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