fzdwx

fzdwx

Hello , https://github.com/fzdwx

Code:alias Translation: Code:alias

Idea#

Currently, there is an idea to manage scripts in the command line.

For example, let's say I have some commonly used scripts:

cd $(find . -name "*" -type d | fzf)

Then, add it through the command line:

cli load "cd $(find . -name "*" -type d | fzf)" -alias cdf

And use cdf to run it:

cli cdf 

Next Steps#

2022-10-18 22:47

I just found a project that aligns well with my idea: https://github.com/denisidoro/navi.

I spent the whole evening researching the feasibility of the technology, but couldn't achieve the desired result. Using the example cd $(find . -name "*" -type d | fzf), there are mainly two approaches:

  1. Utilize shell's tab completion when running the program, directly replace it with this command, and then run it. For example, if the program is called qwe, input qwe cdf<TAB> in the shell, and it will be replaced with the above command. I found the cobra package in Go, which can provide dynamic command completion, but it's not enough and cannot achieve complete replacement, so I put it aside.
  2. Run this command directly in the program. After trying it, it didn't work. The cd command didn't take effect, probably related to fork.

Then I looked for other people's implementations on GitHub and unexpectedly found one, but after trying it, it still doesn't support what I want, although it is well done.

To achieve the desired result, I need to:

  1. Have complete replacement in shell completion, not just a portion.
  2. Run without using fork in the program.

I still need to look into it.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.