I have a gitconfig like this:
[alias]
l = "!source ~/.githelpers && pretty_git_log"
When I run it I get this:
[desktop] git l
source ~/.githelpers && pretty_git_log: 1: source: not found
error: cannot run source ~/.githelpers && pretty_git_log: No such file or directory
fatal: While expanding alias 'l': 'source ~/.githelpers && pretty_git_log': No such file or directory
When I add any other shell builtins to test, they run fine:
[alias]
l = "!echo running from the builtin"
[desktop] git l
running from the builtin
Any idea why the source command can’t be found from git? I am running zsh, but changing to bash didn’t seem to make a difference:
[desktop] bash
[desktop] git l
source ~/.githelpers && pretty_git_log: 1: source: not found
error: cannot run source ~/.githelpers && pretty_git_log: No such file or directory
fatal: While expanding alias 'l': 'source ~/.githelpers && pretty_git_log': No such file or directory
The failure comes from the fact that the
!<command>construct tries to find a program by that name to run. There is a/bin/echoprogram (which is different from your shell’s built inecho, but that’s a different story), but there is not a/bin/source(or/usr/binor any other place). By nature of whatsourcedoes, it cannot be a separate program.Try this instead:
Change
shtobash(or whatever) as necessary.