Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use current word as initial query for fzf #114

Open
bonnefoi opened this issue Feb 16, 2024 · 1 comment
Open

Use current word as initial query for fzf #114

bonnefoi opened this issue Feb 16, 2024 · 1 comment

Comments

@bonnefoi
Copy link

bonnefoi commented Feb 16, 2024

Hello,

I have modified extrakto.sh to use a query initialized to the current word before the cursor:

        esac
    }
    query="$($HOME/bin/tmux_get_cursor_position)"
    while true; do
        header=$header_tmpl
        header=${header/:ga:/$grab_area}
        header=${header/:filter:/$mode}

The content of the script tmux_get_cursor_position:

# from https://unix.stackexchange.com/questions/714209/get-cursor-location-in-tty-without-reading-from-stdin-need-help-with-redirectio/714322#714322
#!/bin/bash
_fetch_cursor_position() {
  local pos
  pos="$(tmux display-message -p -F '#{cursor_x} #{cursor_y}')"
  _cursor_row="${pos#* }"
  _cursor_col="${pos% *}"
}
_fetch_cursor_position
cursor_line="$(tmux capture-pane -p -S $(( $_cursor_row )) -E $_cursor_row)"
last_word="${cursor_line:0:${_cursor_col}}"
[[ "$last_word" =~ ([^ ])+$ ]]
prefix="${BASH_REMATCH}"
echo $prefix

Do you think it's possible to make it works as the query is added to the result ?

@laktak
Copy link
Owner

laktak commented Apr 7, 2024

Sorry, I missed your question ... although I'm not exactly sure what you are asking. Are you trying to make it work like autocomplete?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants