[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to bind key to search for a file and paste the path to the comma
From: |
Marcin Barczyński |
Subject: |
Re: How to bind key to search for a file and paste the path to the command line? |
Date: |
Fri, 20 Mar 2020 06:42:27 +0100 |
On Thu, 19 Mar 2020, 18:59 Greg Wooledge, <address@hidden> wrote:
>
> On Thu, Mar 19, 2020 at 06:22:18PM +0100, Marcin Barczyński wrote:
> > To make my life easier I would like to bind Ctrl-F to run "find . | fzf"
> > and insert the path at the position of cursor:
> >
> > $ cat <Ctrl-F> # runs find . | fzf
> > $ cat /my/script
>
> Inserting text into bash's editing input buffer can be done by the
> manipulation of certain internal readline variables. Here's a function
> that inserts a static string into the editing buffer, as if the user
> had typed it:
>
> stuff() {
> local pre="${READLINE_LINE:0:$READLINE_POINT}"
> local suf="${READLINE_LINE:$READLINE_POINT}"
> local stuff='my string here'
> READLINE_LINE="${pre}$stuff$suf"
> ((READLINE_POINT += ${#stuff}))
> }
Thank you. That's what I need.