kyoheiu / felix

tui file manager with vim-like key mapping
https://kyoheiu.dev/felix/
MIT License
708 stars 24 forks source link

How to configure lwd functionality in the fish environment? #241

Open SadSock opened 11 months ago

SadSock commented 11 months ago

How to configure lwd functionality in the fish environment?

kyoheiu commented 11 months ago

Hi, Currently the script is for POSIX shell, and does not work in fish as is. I, as a someone who doesn't know anything about fish, believe that it should work though by replacing it in fish syntax and add to config file of fish. Could you give it a try?

FYI, fx --init outputs these lines:

  eval "$(
    if [ -n "$XDG_RUNTIME_DIR" ]; then
      runtime_dir="$XDG_RUNTIME_DIR/felix"
    elif [ -n "$TMPDIR" ]; then
      runtime_dir="$TMPDIR/felix"
    else
      runtime_dir=/tmp/felix
    fi

    mkdir -p "$runtime_dir"

    # Clean up leftover LWD files
    find "$runtime_dir" -type f -and -mmin +1 -delete

    cat << EOF
fx() {
  local RUNTIME_DIR="$runtime_dir"
  SHELL_PID=\$\$ command fx "\$@"

  if [ -f "\$RUNTIME_DIR/\$\$" ]; then
    cd "\$(cat "\$RUNTIME_DIR/\$\$")"
    rm "\$RUNTIME_DIR/\$\$"
  fi
}
EOF
  )"
SadSock commented 11 months ago

Sorry all, it looks like this task is beyond my abilities.

Parzival1918 commented 7 months ago

I found a workaround using https://github.com/edc/bass plugin for fish.

Basically I created a function felix in functions/ dir that runs:

function felix
    bass "source <(fx --init); fx $argv"
end

and then the ZQ command in felix changes to the LWD as expected. Hope that helps!