-
-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clifm understands shell functions (e.g. zoxide in zsh) - feature request #200
Comments
Hi @knodalyte! I guess it's possible, everything is it, by I'm not sure about the implementation details. For the time being, the first thing coming to my mind is a plugin: nnn has a plugin for several dir jumpers (including zoxide), which I think could be easily adapted to clifm. Let me take a look at it. I will try the plugin approach first. |
#!/bin/sh
# Description: Jump to visited directories using external directory jumpers
# Author: L. Abramovich
# License: GPL3
#
# Dependencies: zoxide
if type zoxide >/dev/null 2>&1; then
if type fzf >/dev/null 2>&1; then
dir="$(zoxide query -i -- "$@")"
else
dir="$(zoxide query -- "$@")"
fi
[ -n "$dir" ] && echo "$dir" > "$CLIFM_BUS"
fi
exit 0 Hey @knodalyte, here's the first version of the plugin, for the time being supporting only Here's how to install the plugin:
This method has a few drawbacks however:
As a workaround for the second point, and I'm just thinking aloud, clifm's prompt commands might be used to update the zoxide database (using the |
UPDATE To keep the zoxide database up to date, add this prompt command to clifm's main config file ( promptcmd zoxide add -- "$PWD" NOTE: This is exactly the same thing |
UPDATE 2 There's still one thing that needs to be figured out: when running on a regular shell, |
UPDATE 3 To avoid adding the current directory once and again, replace the above promptcmd line promptcmd zoxide add -- "$PWD" by this one: promptcmd [ "$(cat /tmp/z_oldpwd)" != "$PWD" ] && zoxide add -- "$PWD" && echo "$PWD" > /tmp/z_oldpwd Sadly, we need to store the last added directory in a file (plus a command call: |
Thank you for a quick solution! As you pointed out, this more or less works, but it's the parts that don't work that provide most of the utility of zoxide. I think I had unrealistic expectations about the extent the clifm command line would function like a commandline outside of clifm. Of course, the overhead of popping in and out of clifm is low enough that jumping back and forth is probably the best solution. On a separate but related note, I would have expected that using the ; command would allow me to use shell functions like zoxide, so if my command was something like ;z proj but instead clifm tells me "sh: 1: z: not found". |
Thanks for you feedback @knodalyte! As to the However, trying to make I think I will keep working on this plugin: it at least provides a nice integration with |
Btw, which are exactly those parts that don't work? Are you referring to autosuggestions and TAB completion, or is it something else? |
Yes, exactly, as you pointed out, they are suggestions and tab completion. I also found an old utility, xd, that is supposed to provide a quick way to change directories, you might want to see if it has any useful ideas for clifm. |
Is your feature request related to a problem? Please describe.
Is is possible to either set something in the config file(s) or modify how clifm interoperates with my shell (zsh in my case) so that I can use shell functions from within clifm? For example, I would prefer to use zoxide to change directories in both zsh and in clifm, so that I don't have separate directory histories in each.
Describe the solution you'd like
For example, having configured zoxide in my .zshrc, in clifm I could use the z command to change directories, similar to using the existing clifm j command.
Describe alternatives you've considered
Use z in shell and j in clifm
Additional context
If this can be supported, I suspect other shell functions will be usable (nothing in mind right now...)
The text was updated successfully, but these errors were encountered: