Giter Club home page Giter Club logo

xontrib-z's Introduction

xontrib-z

Port of z to xonsh.


Installation

Just do a

pip install xontrib-z

or you can clone the repo with pip

pip install git+https://github.com/AstraLuma/xontrib-z

Configuration

To automatically load z startup, put

xontrib load z

in your .xonshrc

Environment variables

The location of the data file is determined by setting the environment variable _Z_DATA (default ~/.z if not set).

  • Ignore case-sensitive matching by setting _Z_CASE_SENSITIVE to False.
  • Exclude directories from consideration by adding them to _Z_EXCLUDE_DIRS.
  • Ignore symlinks by setting _Z_NO_RESOLVE_SYMLINKS to True.

xontrib-z's People

Contributors

arnfaldur avatar astraluma avatar bn-jbischko avatar con-f-use avatar laloch avatar marsoft avatar stlehmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

xontrib-z's Issues

Option for case insensitive search

Wondering if is possible to ignore cases on search queries. I had the vanilla "z" before migrating to xonsh and my muscle memory used to type only on lowercases

Problems on Windows

Might be unique to my laptop, but

xonsh: To log full traceback to a file set: $XONSH_TRACEBACK_LOGFILE = <filename>
Traceback (most recent call last):
  File "C:\Users\James\AppData\Local\Programs\Python\Python35\lib\site-packages\xonsh\events.py", line 136, in fire
    rv = handler(*pargs, **kwargs)
  File "C:\Users\James\AppData\Local\Programs\Python\Python35\lib\site-packages\xontrib\z.py", line 211, in cd_handler
    self.add(self.getpwd())
  File "C:\Users\James\AppData\Local\Programs\Python\Python35\lib\site-packages\xontrib\z.py", line 192, in add
    self.save_data(data)
  File "C:\Users\James\AppData\Local\Programs\Python\Python35\lib\site-packages\xontrib\z.py", line 119, in save_data
    shutil.copy(f.name, self.Z_DATA)
  File "C:\Users\James\AppData\Local\Programs\Python\Python35\lib\shutil.py", line 235, in copy
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "C:\Users\James\AppData\Local\Programs\Python\Python35\lib\shutil.py", line 114, in copyfile
    with open(src, 'rb') as fsrc:
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\James\\AppData\\Local\\Temp\\tmp6uhp2152'
Exception raised in event handler; ignored.

Deprecation warning on exiting xonsh

Exiting xonsh 0.8.0 I get this, when I have z loaded:

$ exit

/Users/klay6683/miniconda3/lib/python3.6/site-packages/xonsh/__amalgam__.py:21808: DeprecationWarning: __xonsh_env__ has been deprecated, please use __xonsh__.env instead.
  DeprecationWarning,

How to excute this package from xonsh script

When use z in command line its work as normal
But when pass to script and excute this script it show error not found this binary
xonsh: subprocess mode: command not found: z

Did you mean one of the following?
    w:   Command (/bin/w)
    xz:  Command (/bin/xz)
    7z:  Command (/bin/7z)
    X:   Command (/bin/X)
    uz:  Command (/bin/uz)

I try to find where is z binary with which but don't found, seem like xontrib package not work as a binary or a alone python script file. In /usr/share/python3/.../xontrib/z.py i cannot exexcute it too(and also i require root permission).
=> In short I want to ask how to pass z to a script

'cd' causes an error

When I change directories with 'cd' I get the following debug info:

grove@grove-UX302LG ~ $ cd
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/xontrib/z.py", line 205, in cd_handler
self.add(self.getpwd())
File "/usr/local/lib/python3.4/dist-packages/xontrib/z.py", line 177, in add
data = list(self.load_data())
File "/usr/local/lib/python3.4/dist-packages/xontrib/z.py", line 85, in load_data
with open(self.Z_DATA, 'rt') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/grove/.z'

Any ideas?

Simple releasing the PyPi package using Github Actions

Hi! Just want to let you know that there is very easy way to release the PyPi package of xontrib using Github Actions:

  1. Click Actions

Screenshot_20200916_115026

  1. Click Set up workflow on Publish Python Action

Screenshot_20200916_114928

  1. Commit the config without any changes

  2. Go to repo Settings - Secrets and add:

Screenshot_20200916_115332

  1. Now when you create Release and the Actions will publish the package to PyPi automatically (look at Actions link)

Enjoy :)

__xonsh_env__ is now __xonsh__.env From xonsh 0.8.x

Hi

xonsh_env has been deprecated from xonsh 0.8.0.
https://github.com/xonsh/xonsh/blob/7fbf172b5e227ac23aa950b624006f37671c6d01/CHANGELOG.rst

So, The following alert will continue always.

xonsh/built_ins.py:1455: DeprecationWarning: __xonsh_env__ has been deprecated, please use __xonsh__.env instead.
  DeprecationWarning,
+------------------+---------------------+
| xonsh            | 0.8.0               |
| Git SHA          | aca294b8            |
| Commit Date      | Oct 7 09:53:16 2018 |
| Python           | 3.6.3               |
| PLY              | 3.9                 |
| have readline    | True                |
| prompt toolkit   | 2.0.5               |
| shell type       | prompt_toolkit2     |
| pygments         | 2.2.0               |
| on posix         | True                |
| on linux         | True                |
| distro           | CentOS Linux        |
| on darwin        | False               |
| on windows       | False               |
| on cygwin        | False               |
| on msys2         | False               |
| is superuser     | False               |
| default encoding | utf-8               |
| xonsh encoding   | utf-8               |
| encoding errors  | surrogateescape     |
+------------------+---------------------+

Deprecation warning with python3.12

Causes the following errors:

/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/xontrib/z.py:188: DeprecationWarning: datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.now(datetime.UTC).
  now = datetime.datetime.utcnow()
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/xontrib/z.py:95: DeprecationWarning: datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.fromtimestamp(timestamp, datetime.UTC).
  t = datetime.datetime.utcfromtimestamp(int(t))

$_Z_EXCLUDE_DIRS ignored

ZHandler.__init__ reads $_Z_EXCLUDE_DIRS.
However, neither cmd_handler nor ZHandler.add check against this list.

Example:

$ $_Z_EXCLUDE_DIRS = ['/tmp', '/tmp/a']
$ $_Z_DATA = '/tmp/z'
$ cat /tmp/z
/tmp|1|1536146454
$ mkdir a
$ cd a
$ cd ..
$ cat /tmp/z
/tmp|4|1536146468
/tmp/a|1|1536139266

Expected /tmp/z to be empty

How to use 'z' : Getting ValueError

I assumed since this is a port of z, I just do z dirname but it lead to a crash

mandar@MacBook-Pro ~ $ z src
xonsh: To log full traceback to a file set: $XONSH_TRACEBACK_LOGFILE = <filename>
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/xonsh/__amalgam__.py", line 9468, in wrapped_simple_command
    r = f(args, i)
  File "/usr/local/lib/python3.5/site-packages/xontrib/z.py", line 197, in handler
    return cls()(args, stdin)
  File "/usr/local/lib/python3.5/site-packages/xontrib/z.py", line 141, in __call__
    data = list(self.load_data())
  File "/usr/local/lib/python3.5/site-packages/xontrib/z.py", line 89, in load_data
    r = int(r)
ValueError: invalid literal for int() with base 10: '4.28733'

After that, normal cd also leads to this error (although cd itself works)

mandar@MacBook-Pro ~ $ cd /tmp
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/xontrib/z.py", line 205, in cd_handler
    self.add(self.getpwd())
  File "/usr/local/lib/python3.5/site-packages/xontrib/z.py", line 177, in add
    data = list(self.load_data())
  File "/usr/local/lib/python3.5/site-packages/xontrib/z.py", line 89, in load_data
    r = int(r)
ValueError: invalid literal for int() with base 10: '4.28733'
mandar@MacBook-Pro /tmp $

In case it matters, I am on xonsh/0.4.5 on OSX

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.