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:
- 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
, inputqwe cdf<TAB>
in the shell, and it will be replaced with the above command. I found thecobra
package in Go, which can provide dynamic command completion, but it's not enough and cannot achieve complete replacement, so I put it aside. - Run this command directly in the program. After trying it, it didn't work. The
cd
command didn't take effect, probably related tofork
.
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:
- Have complete replacement in shell completion, not just a portion.
- Run without using
fork
in the program.
I still need to look into it.