fzf bash refresh / re expannd and substitute $() and `` var expansion with binding in --reload() option

25 Views Asked by At

I'm trying to develop a fzf file explorer that will have an abillity to toggle between differeteny dirr sources AND toggle between file / Dir anme based search for now.

fzfCd() {
  local MY_ARR=("Hello" "There")\

  local FILE_PICKER_CMD="fd --hidden"
  set -x
  local SearchPath=~
  local dir
  dir=$(fd --type file --hidden .  | fzf-tmux --ansi \
    --header "CTRL-T: Switch between Files/Directories CTRL-Y Yank marked" \
    --bind "ctrl-r:execute(echo \"~/.config\" > /tmp/fpicker-dir)" \
    --bind "ctrl-e:execute(echo . > /tmp/fpicker-dir)" \
    --bind "ctrl-t:transform:[[ ! {fzf:prompt} =~ Files ]] &&
      echo \"change-prompt(Files `cat /tmp/fpicker-dir`)+reload(${FILE_PICKER_CMD} --type file . {+1})\" ||
      echo \"change-prompt(Dirs  `cat /tmp/fpicker-dir`)+reload(${FILE_PICKER_CMD} --type directory . `cat /tmp/fpicker-dir`)\"" \
    --preview "[[ $FZF_PROMPT =~ Files ]] && bat --color=always {} || tree -C {}" \
    --prompt "/home/pong/" \
    +m)

    [[ ${#dir} != 0 ]] || return 0 && builtin cd "$dir" &> /dev/null # check if $dir is not empty l
    xdotool key Return 
    set +x

}

++ctrl+r++ and ++ctrl+e++ suppose to change the dir search source and ++ctrl+t++ toggles between Files OR Directory search with the choosen search dir source.

Basically cat /tmp/fpicker-dir work once after changing the dir search in fzf and because it "persists" in the file relaunching fzf refreshed the search dir BUT doesn't do it while staying in fzf.

Any idea why / any good workaround?

0

There are 0 best solutions below