felix icon indicating copy to clipboard operation
felix copied to clipboard

How to configure lwd functionality in the fish environment?

Open SadSock opened this issue 11 months ago • 3 comments

How to configure lwd functionality in the fish environment?

SadSock avatar Sep 25 '23 08:09 SadSock

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
  )"

kyoheiu avatar Sep 25 '23 20:09 kyoheiu

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

SadSock avatar Sep 28 '23 06:09 SadSock

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!

Parzival1918 avatar Jan 17 '24 19:01 Parzival1918