Comments (11)
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.
(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.
Thanks for the quick reply,
This is the issue i am facing, z
command is not found
I wanted to replace the below logic with a subprocess call to zshz
from zsh-z.
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.
Ah, subprocess.run()
works with the same arguments.
from zsh-z.
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.
Is there any way to get file location of zsh-z.plugin.zsh. From environment or something.
from zsh-z.
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.
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.
Yeah i was also thinking of creating a environment variable pointing to the script. Thank you for helping.
from zsh-z.
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)
- Request: Please sign up for Github Sponsors HOT 3
- Crash after installation HOT 3
- Show tilde instead of HOME during tab completions? HOT 3
- Directories with spaces don't get updated correctly HOT 6
- Files and directories both display in autocompletions HOT 4
- Strange file created in home directory HOT 3
- Fzf Integration HOT 2
- allow manually adding an alias for a directory HOT 2
- Feature request: Navigate up 'n' directories HOT 4
- Info: Ranger plugin HOT 5
- When setting `ZSHZ_DATA` to an XDG basedir location, the directory doesn't get created HOT 2
- Machine arm64 not supported by this plugin HOT 2
- Use preexec hook to also index the files from the commnd line
- doesn't work with prezto: "pmodload: no such module: zsh-z" HOT 1
- Autocompletion with `zap` package manager HOT 6
- Completion doesn't work HOT 7
- tmpfd file error on macOS / zinit installation HOT 1
- `ZSHZ[CHOWN,RM,MV]` aren't set when user loads zsh/files early HOT 2
- Performance Delay After Using z Command to Navigate Directories HOT 3
- [Need help]How to set the variables for zsh-z? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zsh-z.