0

When I try to enter an alias into the less or vim command lines, they both print “/bin/bash: [MY ALIAS]: command not found”

This alias is defined in .bashrc or .bash_login and is there a way to source these files into the vim and less command prompts?

1 Answer 1

1

At least for Vim, you can use the following in your .vimrc:

set shellcmdflag=-ic

There's a call out for that in :help :!cmd:

On Unix the command normally runs in a non-interactive shell. If you want an interactive shell to be used (to use aliases) set 'shellcmdflag' to -ic.

Not sure whether you can do the same in less...

But note that generally it's not a great idea to call aliases from shelling out of these tools, since aliases are mostly meant for interactive use of the shell, or for commands that change the state of the current shell (change directory, export new variables, etc.) For all else, using external commands (which can be implemented using shell scripts) are usually a better choice.

So maybe consider doing that instead, replacing aliases with shell scripts in a directory you add to $PATH, which will be naturally available to all your tools which are able to shell out.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .