[Top][All Lists]

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

Re: Nano

From: Chris Allegretta
Subject: Re: Nano
Date: Wed, 23 Feb 2022 08:31:31 +0000

Hello there,

When invoking a command under nano (^R^X), the normal bash user scripts (like 
~/.bashrc) are not referenced by default. This is due to how non-interactive 
shell invocation works; you can read the bash man page or related documentation 
for interactive vs non-interactive shell invocation for more details.

Anyway, in the case of how nano executes commands, the bash shell looks for an 
environment variable named $BASH_ENV to know where to load any needed variables 
or functions. Generally this variable is not set, just to keep these 
non-interactive shells as minimal and fast as possible. However, you can set 
this BASH_ENV value to whatever you want before you execute nano to make it 
load your custom functions:

BASH_ENV=$HOME/.bashrc  # or some other file if you prefer
export BASH_ENV

Unfortunately many Unix and Linux distributions set up the .bashrc to check for 
whether they are running interactively. This checks looks like this on my 
  # If not running interactively, don't do anything
  case $- in
     *i*) ;;
       *) return;;

So you will have to put the BASH_ENV lines (and your custom functions) above 
this check in your .bashrc, ideally right at the top of the file. If all goes 
well, it should work.

If this becomes problematic, you should find that executing something like 
"bash -i -c myfunction" from within nano instead of just "myfunction" would 
work instead of doing the above.

I hope this helps.

------- Original Message -------
On Monday, February 21st, 2022 at 11:54 PM, BZ <> 

> Hello,
> I'm BM. A very nice and polite guy.
> I often look at webpages in nano and then I need to copy the urls.
> So I was thinking I'll write a function for this and use it with the Nano 
> Terminal (Ctrl+T). The function will just store urls into a list that I can 
> edit later.
> However when I try to use my own custom made bash functions in Nano I get 
> this error message: command not found.
> I can however run my own funcitons in bash as usual.
> Any way that I can use functions in the Nano Terminal so that I can 
> conveniently save URLs to a file?
> BM

reply via email to

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