0

I would like to set up a few straight alias (without fixed ARGS) for some external executables in Eshell that need access to the command-line ARGS (that will vary). The function eshell-maybe-replace-by-alias is expressly designed to omit the ARGS.

EXAMPLE: The alias file within the Eshell folder [eshell-aliases-file] contains the following entries below. When I call git diff SHA1234567890 > patch.diff, eshell-maybe-replace-by-alias excludes diff SHA1234567890 and the patch file that gets created is a printout from git telling me what types of command line options are possible -- this is because git was called by Eshell without any arguments.

alias git /Users/HOME/.0.data/.0.emacs/.0.macports/bin/git
alias curl /Users/HOME/.0.data/.0.emacs/.0.macports/bin/curl

I hacked the last line of eshell-maybe-replace-by-alias to include the ARGS [i.e., ,(eshell-parse-command (nth 1 alias) args)], but have a feeling that there may be an existing method to better handle this dilemma.

I played around with creating a custom function named eshell/COMMAND, but ran into several problems with with pre/post command hooks needing to be suppressed the first loop; an extra \n that needed to be suppressed the second loop; escaping double-quotes (of strings greater than one word) in order to survive the first loop; and, an unresolved issue when dealing with redirection >. Therefore, the hack of eshell-maybe-replace-by-alias seems the easiest approach so far.

[I feel as though a bug report is not the right avenue at this point because Emacs 26 expressly has the ARGS labeled as _args; i.e., disregard the ARGS.]

  • I don't know much about eshell so I'm not the person to help here, but FWIW I found the question a bit confusing, and suspect that some concrete examples would clarify both the problem, and what you would like to achieve. – phils Sep 4 '18 at 5:29
  • @phils -- thank you for the constructive help. I added a specific example to the question above. – lawlist Sep 4 '18 at 6:08
  • If you want to pass arguments to the alias, its definition needs to end in '$*' (the eshell info manual is short but pretty clear) – rpluim Sep 4 '18 at 8:17
2

According to @rpluim's comment and (eshell) Aliases:

Note that unlike aliases in Bash, arguments must be handled explicitly.

Here is the way to create an alias to git:

$ alias git '/usr/local/bin/git $*'

The above Eshell command will write the following to eshell-aliases-file:

alias git /usr/local/bin/git $*

BTW, as you can see Eshell command line and eshell-aliases-file don't use the exactly same syntax (i.e, the quote), and the difference does matter according to my test. This is weird,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.