Code Monkey home page Code Monkey logo

Comments (11)

agkozak avatar agkozak commented on May 18, 2024

It actually already works for me -- neat!

But I keep my database in the default place -- ~/.z. Where do you keep yours? Let's get it working for you, and then we can think about how to make it it work for all users by tweaking that one line (I think that's all it will take).

from zsh-z.

agkozak avatar agkozak commented on May 18, 2024

(The file format is identical to that of rupa/z, so I think we can get your plugin working for people regardless of which shell or tool they're using.)

from zsh-z.

ask1234560 avatar ask1234560 commented on May 18, 2024

Thanks for the quick reply,

This is the issue i am facing, z command is not found
image

I wanted to replace the below logic with a subprocess call to zshz
image

from zsh-z.

agkozak avatar agkozak commented on May 18, 2024

You're going to want to have the program look for the database in

  • ZSHZ_DATA -- or, if it's empty, then
  • _Z_DATA -- which is also valid, or, if that's empty, then
  • ${HOME}/.z

You've got the second two accounted for. I tried

z_loc = getenv("ZSHZ_DATA") or getenv("_Z_DATA") or getenv("HOME")+"/.z"

and it seems to do the trick: I can set ZSHZ_DATA to whatever I want, and ranger (with your plugin) searches that file.

I'm not very proficient in Python, but here's what I do know. Zsh-z is not an executable; it has to be sourced into the shell and then run. So I suspect the right way to run it would be

subprocess.run(['zsh', '-c', 'source /path/to/zsh-z.plugin.zsh && zshz'])

See if you can get that to do what you want (you'll need to provide the appropriate path to the script, of course).

from zsh-z.

agkozak avatar agkozak commented on May 18, 2024

Ah, subprocess.run() works with the same arguments.

from zsh-z.

ask1234560 avatar ask1234560 commented on May 18, 2024

Thanks you,

subprocess.check_output(['zsh', '-c', 'source /path/to/zsh-z.plugin.zsh && zshz'])

It worked, this is exactly what i was looking for.

from zsh-z.

ask1234560 avatar ask1234560 commented on May 18, 2024

Is there any way to get file location of zsh-z.plugin.zsh. From environment or something.

from zsh-z.

ask1234560 avatar ask1234560 commented on May 18, 2024

The below one is working as expected with lesser lines of code. The only thing remaining is to dynamically find the location of zshz source file.

import ranger.api
from ranger.api.commands import *
from subprocess import check_output


class z(Command):
    """:z
    Uses .z file to set the current directory.
    """

    def execute(self):
        try:
            arguments = 'source /home/ananthu/.config/.zplug/repos/agkozak/zsh-z/zsh-z.plugin.zsh && zshz -e ' + \
                " ".join(self.args[1:])
            directory = check_output(
                ['zsh', '-c', arguments]).decode().rstrip("\n")
            self.fm.execute_console("cd " + directory)
        except Exception as e:
            raise Exception("Directory not found")

from zsh-z.

agkozak avatar agkozak commented on May 18, 2024

Perhaps the best thing to do would be to have an environment variable pointing to the script? The script isn't necessarily going to be in the PATH or the FPATH. The other thing you could do would be to install Zsh-z as a Git submodule inside your project so that the file would always be in a predictable subdirectory.

from zsh-z.

ask1234560 avatar ask1234560 commented on May 18, 2024

Yeah i was also thinking of creating a environment variable pointing to the script. Thank you for helping.

from zsh-z.

agkozak avatar agkozak commented on May 18, 2024

Yeah i was also thinking of creating a environment variable pointing to the script. Thank you for helping.

That sounds like a great idea. Good luck!

from zsh-z.

Related Issues (20)

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.