help-bash
[Top][All Lists]
Advanced

[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: Greg Wooledge
Subject: Re: How to bind key to search for a file and paste the path to the command line?
Date: Thu, 19 Mar 2020 13:58:58 -0400
User-agent: Mutt/1.10.1 (2018-07-13)

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]