> As a general rule, if I want to use something outside of the interactive
> shell, I use an executable. This applies equally as well to things like
> running :!theCommand from within vim to running theCommand remotely via ssh
> to creating desktop shortcuts that search the $PATH.
According to the Bash manual (man 1 bash), one can use shopt to set
expand_aliases to true. This should allow access to aliases in
non-interactive settings. (I have not tested it, though.)
A workaround I came across a long time ago was to keep aliases in a
separate file, which gets sourced by ~/.bashrc, but which can also be
sourced by a wrapper script like so:
```
#! /bin/bash
. ~/bashrc.d/aliases.sh
ALIAS=$1
ARGS=${@:2}
bash -c "${BASH_ALIASES[$ALIAS]} $ARGS"
```
So, if ~/bashrc.d/aliases.sh contains the line `alias foo="vim ~/bar"`, and
if that wrapper script is named `baz` somewhere in my $PATH, this should
work in non-interactive settings:
baz foo
It will source the aliases file, find the alias foo, and thus execute
`vim ~/bar`.
But if using shopt to set expand_aliases works, it is probably a superior
approach to my workaround.
~ Tim