help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Only set VISUAL for edit-and-execute-command


From: Koichi Murase
Subject: Re: Only set VISUAL for edit-and-execute-command
Date: Thu, 30 May 2024 05:53:42 +0900

2024年5月24日(金) 13:43 Mike <nvimmike@gmail.com>:
> I am working on a script that I'd like to be invoked
> by edit-and-execute-command. Currently, it works fine if I set the VISUAL
> environment variable and press C-xC-e. However, I don't want to set VISUAL
> to this script globally because I only want it to run in the context of
> C-xC-e. I'd like to keep VISUAL set to nvim so that other applications can
> still use VISUAL as expected.

I think the typical solution people use is to prepare a small script
(such as ~/bin/custom-visual-selector) like

  #!/usr/bin/bash env
  if [[ $1 == *bash-fc* ]]; then
    exec script-to-be-invoked-by-edit-and-execute "$@"
  else
    exec nvim "$@"
  fi

and put it in VISUAL

  VISUAL=custom-visual-selector

--
Koichi



reply via email to

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