1

I'm trying to get Emacs eshell to use the same alias' as bash.

I tried following the wisdom in the top comment from Stackoverflow here, which was to add these two lines to the .emacs profile:

(setq shell-file-name "bash")
(setq shell-command-switch "-ic")

but nothing happened.

Then I tried this wiki option here. Which is to have the bash alias script overwrite the emacs eshell alias file whenever a new terminal opens:

alias | sed -E "s/^alias ([^=]+)='(.*)'$/alias \1 \2 \$*/g; s/'\\\''/'/g;" >~/.emacs.d/eshell/alias 

However, this one results in an error when I open a new terminal (note that running it with a capital -E doesn't work for me):

sed: -e expression #1, char 42: invalid reference \2 on 's' commands' RHS.

Would anyone know how to go about resolving this sed error? I realize the wiki option specifically points to using .bashrc - admittedly, I don't know how this is different from the ~/.alias file I've been using.

For example, I have a .alias file like so:

#!/bin/bash
alias episas="nice -19 perl $EPI/analysis/scripts/episas ";

 alias | sed -e "s/^alias ([^=]+)='(.*)'$/alias \1 \2 \$*/g; s/'\\\''/'/g;" >~/.emacs.d/eshell/alias

and I want my /.emacs.d/eshell/alias file to have the same alias for episas.

Thank you for any help!

Ruminare
  • 47
  • 7
  • it'd help if you post few sample lines from output of `alias` and show expected output for those lines.. – Sundeep Feb 26 '18 at 14:36
  • or try to find a minimal example to reproduce the error.. I don't see an error when I try this: `echo "alias c='clear'" | sed -E "s/^alias ([^=]+)='(.*)'$/alias \1 \2 \$*/g; s/'\\\''/'/g;"` – Sundeep Feb 26 '18 at 14:39
  • Are you sure it calls the same `sed`? Try specifying the full path. – choroba Feb 26 '18 at 14:42
  • Thanks Sundeep, I added an example to clarify what I'm asking for. My alias' list is really simple in the bash .alias file, and I want my Emacs eshell alias list to have the same items. – Ruminare Feb 26 '18 at 14:45
  • Thanks choroba - I'm not sure how to determine which sed it uses. Admittedly new to sed, but when I use which sed, I get: /usr/bin/sed and changing it to use the full path doesn't resolve it. – Ruminare Feb 26 '18 at 14:52
  • the two given lines won't match any of the two sed commands.. so not a good sample... anyway, here's another thing you can try (use a copy of alias file) ... delete lines from the copy file until you see the error.. that will narrow down cause of error – Sundeep Feb 26 '18 at 14:59
  • The `-E` just provides syntactic sugar try `sed -e "s/^alias \([^=][^=]*\)='\(.*\)'$/alias \1 \2 \$*/g; s/'\\\''/'/g;" file` – potong Feb 26 '18 at 15:42
  • Thank you @potong! That worked! – Ruminare Feb 27 '18 at 08:45

0 Answers0