Skip to content

How to edit command line in vim / copy command line to clipboard / bind fzf-file-widget? #96

@MaxGyver83

Description

@MaxGyver83

Thank you for implementing rc for Linux! I'm new to it and I have some questions:

Can I achieve any of the following in rc (with readline support):

Edit command line in vim

I have this in my .inputrc:

# edit command line in vim
"\ev": edit-and-execute-command

This does not work in rc because it's a bash function. I think it belongs into my .bashrc then. Could I replace edit-and-execute-command with an equivalent rc function? Would this have to be done in rc's source code?

Copy the current command line to the clipboard

I have this in my .bashrc:

copy_line_to_x_clipboard () {
  # using OSC 52
  printf "\e]52;c;%s\a" "$(printf %s "$READLINE_LINE" | openssl base64 -A)"
}
# bind to Ctrl-Shift-x
bind -x '"\C-X": copy_line_to_x_clipboard'

I have adapted this function for rc (in my .rcrc):

fn copy_line_to_x_clipboard {
	# using OSC 52
	printf '\e]52;c;%s\a' `{printf %s $READLINE_LINE | openssl base64 -A}
}

and moved the binding to C-X into my .inputrc:

"\C-X": copy_line_to_x_clipboard

But it still does not work. Is it possible at all to bind readline keystrokes to rc functions? (Maybe I just got the quotes wrong.)

Use fzf for file selection

More or less the same question: How can I migrate this bash snippet to rc?

  # CTRL-T - Paste the selected file path into the command line
  if [[ "${FZF_CTRL_T_COMMAND-x}" != "" ]]; then
    bind -m emacs-standard -x '"\C-t": fzf-file-widget'
    bind -m vi-command -x '"\C-t": fzf-file-widget'
    bind -m vi-insert -x '"\C-t": fzf-file-widget'
  fi

fzf/shell/key-bindings.bash at 07880ca4415009d7a151d262bc5ac62f8b6dc719 · junegunn/fzf

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions