Skip to content
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

get the path as the argument for any command #500

Closed
zhuzhzh opened this issue Dec 10, 2022 · 3 comments
Closed

get the path as the argument for any command #500

zhuzhzh opened this issue Dec 10, 2022 · 3 comments

Comments

@zhuzhzh
Copy link

zhuzhzh commented Dec 10, 2022

I want to use the path for cp/rm/awk/...

for ex:

cp $(zoxide query -i)<tab>

then it will list the path as zi, I will input the key word and select the path, it becomes

cp /some/path

current, it will break the line. for ex.

/hcp /home/harriszh/.config/nvim/init.lua

I think it will extent zoxide's usage for smart jump, but path selection for any command.

@zhuzhzh
Copy link
Author

zhuzhzh commented Dec 10, 2022

I totally don't know zle. but I emulate fzf's key-binding.

  zoxide-history-widget-accept() {
    local selected
    selected=( $(zoxide query --list |fzf) )
    local ret=$?
    echo -n "$selected"
    return $ret
  }
  zle    -N    zoxide-history-widget-accept
  bindkey '^[o' zoxide-history-widget-accept

It doesn't work.

@ajeetdsouza
Copy link
Owner

@zhuzhzh I'm no zsh expert, but this is how I fixed it:

zoxide-history-widget-accept() {
  res="$(zoxide query -i)" # interactive zoxide query
  LBUFFER+="${(q)res}" # push the result to the input buffer
  zle reset-prompt # redraw the prompt
}

@zhuzhzh
Copy link
Author

zhuzhzh commented Jan 19, 2023

Thanks a lot! It works .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants