How can I resolve a sed invalid reference error when trying to use bash to overwrite Emacs eshell alias list?

168 views Asked by At

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!

0

There are 0 answers