0

I have a few custom bash functions that are defined is some file and are made available to me in regular terminals via the line

. "/path/Custom Bash Functions.sh"

in my ~/.bashrc. However, Emacs does not recognize them.

I don't really care whether they are available in any terminal emulator inside Emacs. I only care about them working when I hit M-!.

This answer suggests setting shell-command-switch to "-ic" (adding switch i to the default). However, all this seemingly results in is that the output of all commands I execute via M-! are preceded by:

bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell

I still can't execute custom bash functions. Auto-complete for them doesn't work either.

Maybe this is because I use a newer version. I use the latest version on the master branch of Emacs' git repo (pulled the latest changes and installed them less than 2 hours ago).

  • 1
    What -i does is to source ~/.bashrc (assuming you use/bin/bash as your shell). So you can put your custom functions in that file, or source your custom functions file from there. That's probably a good idea so you can have your custom functions in a shell without having to source it explicitly every time. The complaints that bash issues however in the -i case probably arise from how emacs sets up the process and probably cannot be avoided. – NickD Nov 2 '18 at 17:42
  • 1
    Adding -i should work. Try adding -ix and post the complete output, preferably with a shorter .bashrc that reproduces the problem. – Gilles Nov 2 '18 at 19:22
  • You're right. Now it works. Thank you. Maybe I simply mistyped my custom command or something in my init file or .bashrc was messing with what I tried to do. Anyway, it works now. However, there still is no auto-complete. I have to type out the entire command. Should auto-complete work? I tested it with emacs -Q and it behaves in the same way: The command works (after evaluating (setq shell-command-switch "-ic")) but it's not auto-completed when I hit <kbd>Tab</kbd>. – UTF-8 Nov 5 '18 at 18:34
  • Emacs behaved really weird today. I just figured out that that was because of these two lines that are printed. I use custom functions that run commands and work on their outputs. Because those two lines were included in those outputs, my functions got confused. I had to undo the change of adding the i switch. – UTF-8 Nov 7 '18 at 15:04

Your Answer

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

Browse other questions tagged or ask your own question.