|
|
|
|
|
by jvanderbot
265 days ago
|
|
You don't even need history. Just `find . -type d | fzf` to determine what dir to change to (or ~ for "anywhere else") 1. Make an alias fcd
2. Make a tab complete that does that for the command fcd This is kind of 101 bash - just DIY. Here's mine: (2) is the hardest part - just write something that works with `complete` and fzf. Nowadays this is childs play for any AI to just spit out. fz_comp()
{
COMPREPLY=()
local cur="${COMP_WORDS[COMP_CWORD]}"
local prev="${COMP_WORDS[COMP_CWORD-1]}"
local opts="none"
if [ -z "$cur" ];then
COMPREPLY=($(find $1 -type d | fzf --preview="ls {} -l"))
return
fi
COMPREPLY=($(find $1 -type d | grep $cur | fzf --preview="ls {} -l"))
}
(1) is just a) set the new command b) make the completion call c) map that call to <TAB> completion. alias fcd=cd
_fcd(){ fz_comp $(pwd) }
complete -F _fcd fcd
there you go. |
|