0

I'm trying to exec an alias while doing a git rebase -i

pick hash commit_message
x alias_name

The error:

Executing: alias_name
error: cannot run alias_name: No such file or directory
warning: execution failed: alias_name
You can fix the problem, and then run

  git rebase --continue

alias alias_name='calls a phyton script to run arc command'

If I do run the alias on the terminal, it works as expected.

T04435
  • 12,507
  • 5
  • 54
  • 54

1 Answers1

0

Git doesn't know about any aliases or shell functions you've defined, so the shell it starts to execute the given command won't know about them either. You'll need to source a file containing the definition of the alias, then enable alias expansion if necessary, in the command itself.

pick hash commit_message
x source some_file; shopt -s expand_aliases; alias_name

where some_file contains your alias definition.

I suspect, though, that this will still fail, because the shell in question will try to expand aliases in that full command line before it actually sources the file or enables alias expansion, leaving alias_name an undefined command name. Replace the alias with a function should work, though.

With

func_name () {
  the_script.py arg1 arg2
}

in an accessible file, do

x source some_file; func_name
chepner
  • 497,756
  • 71
  • 530
  • 681
  • Did not work, here error output: ``` Executing: source ~/.zshrc; grbi_rev source ~/.zshrc; grbi_rev: 1: source ~/.zshrc; grbi_rev: source: not found source ~/.zshrc; grbi_rev: 1: source ~/.zshrc; grbi_rev: grbi_rev: not found warning: execution failed: source ~/.zshrc; grbi_rev ``` ``` #./zshrc file grbi_rev() { USER=T04435 ~/path_to_file/phab arg1 arg2 } ``` I'm trying more variants of your answer but nothing seems to work Sorry for the formating. – T04435 Dec 04 '19 at 12:40