Package: xontrib-onepath
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 to thexonsh 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 click ⭐ on the repo andtweet.Installxpipinstall-Uxontrib-onepathecho'xontrib load onepath'>>~/.xonshrc# Reload xonshExamples# Run:                 # Action that will be executed:/# cd /executable_script# ./executable_script.xonshrc# vim ~/.xonshrc~/Downloads/logo.png# xdg-open ~/Downloads/logo.pnggit# git./git# cd ./gitDefault actionsIf typed command is a registered name (i.e.git) andwhichcommand returns the path (i.e./usr/bin/git) it will be executed.
In other case the typed path will be used to make action. Default actions:PriorityTypeAction1<DIR>cd2<XFILE><RUN>3text/vim4image/xdg-openHelp to add more types and best default actions. PRs are welcome!You can add platform and tool depend actions:import shutil as _shutil
from xonsh.platform import ON_LINUX #, ON_DARWIN, ON_WINDOWS, ON_WSL, IN_APPIMAGE, ON_CYGWIN, ON_MSYS, ON_POSIX, ON_FREEBSD, ON_DRAGONFLY, ON_NETBSD, ON_OPENBSD

xontrib load onepath

if ON_LINUX and _shutil.which('nvim'):
    $XONTRIB_ONEPATH_ACTIONS['text/'] = 'nvim'File types#TypeExample1Full path to file.~/.xonshrc2File name.file.txt3File extension.*.txt4MIME type/subtype and extension.text/plain.txt5MIME type/subtype.text/plain6MIME type.text/7Any file.<FILE>(constant)8Any executable file.<XFILE>(constant)9Any directory.<DIR>(constant)10Any file or directory.*(constant)To get MIME type for the file runfile --mime-type --brief <file>.Examples of actionsUseXONTRIB_ONEPATH_ACTIONSenvironment variable to add new actions.
If you need more complex actions usecallable xonsh aliases.Simple 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['<DIR>']='ls'# list the files in the directory$XONTRIB_ONEPATH_ACTIONS['application/zip']='als'# list files in zip file using atoolRun xsh regardless the execution permissions$XONTRIB_ONEPATH_ACTIONS={'*.xsh':'xonsh',**$XONTRIB_ONEPATH_ACTIONS}# Insert on topxontribloadonepathscript.xsh# the same as:  chmod +x script.xsh && ./script.xshView CSV tables using pandasimportpandasaspddef_view_csv_with_pandas(args):print(pd.read_csv(args[0]))aliases['view_csv_with_pandas']=_view_csv_with_pandasdel_view_csv_with_pandas$XONTRIB_ONEPATH_ACTIONS['application/csv']='view_csv_with_pandas'cd & lsdef_cdls(args):cd@(args[0])ifint($(ls|wc-l).strip())<100:ls--group-directories-first-a--coloraliases['cdls']=_cdlsdel_cdls$XONTRIB_ONEPATH_ACTIONS['<DIR>']='cdls'Known issuesImportError: failed to find libmagicInstall libmagic:brew install libmagic.NTFS in Linux: all files have execute permissionIf you mount NTFS partition with default permissions then all files will have execute permission
andonepathwill execute them instead of action. The right way
is tochange default/etc/fstabsettings.
Example:sudoumount/d
sudomount-ouid=1000,gid=1000,dmask=027,fmask=137/dls-la/dLinksThis package is the part ofergopack- the pack of ergonomic xontribs.This package was created withxontrib template.