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

Type Action
inode/directory ls
text/plain vim
image/ xdg-open

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

Example

$ /
# xontrib run: ls /

$ ~/.xonshrc
# xontrib run: vim ~/.xonshrc

$ ~/Downloads/logo.png
# xontrib run: xdg-open ~/Downloads/logo.png 

Type format

Priority Format Example
1 File name. file.txt
2 File extension. *.txt
3 MIME type/subtype and extension. text/plain.txt
4 MIME type/subtype. text/plain
5 MIME type. text/
6 Any file. FILE
7 Any directory. DIR
8 Any file or directory. *

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

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

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.3.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

xontrib_onepath-0.0.3-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: xontrib-onepath-0.0.3.tar.gz
  • Upload date:
  • Size: 4.4 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.3.tar.gz
Algorithm Hash digest
SHA256 c9e15142ea9591521adf80a485b9501ba37dece72187639b5aa7b3493cca0cda
MD5 a37d838ddce17596d310c2045a1d9549
BLAKE2b-256 15f6226aa3947184fa7f4bb523542b37f9983b061131b658198dae6a01c38306

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xontrib_onepath-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.3 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 eb23bf2743e6e61fbf28a49f473699b1ab6ba0de49a819cfafa9a5c78bae6a7b
MD5 b2b86bea0c0d7ecb4548bf3a12091d55
BLAKE2b-256 1acbe6a80cd43f8d7f2b972dbde70778ad30dffc19399809507eb513c9df145d

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