Hot answers tagged

16 votes

Why does typing '<<<' instead produce '<<EOF\n<' when in shell-script mode?

glucas is exactly correct, but to supplement his answer I have this piece of code I've used myself to make here doc insertion a little smarter. This advice, coupled with sh-electric-here-document-...
user avatar
15 votes
Accepted

.bash_profile or .bashrc for shell in emacs?

This is the correct behaviour. .bash_profile is for so-called login shells. Like when you log in to your computer in text mode, or in a terminal emulator to a different computer via ssh or telnet or .....
user avatar
14 votes
Accepted

Git Bash in emacs on Windows

The ^[] noise is coming from various terminal control characters in your shell prompt. Try echo $PS1 to see the full sequence, and try e.g. export PS1='$ ' to see that a simpler prompt string removes ...
user avatar
  • 19.4k
13 votes
Accepted

Highlighting shell variables within quotes

The code below use a font-lock rule with a function instead of a regexp, the function search for occurrences of $VAR but only when they are inside a double-quoted string. The function (syntax-ppss) is ...
user avatar
  • 5,825
13 votes
Accepted

Why does typing '<<<' instead produce '<<EOF\n<' when in shell-script mode?

This is caused by sh-electric-here-document-mode. When enabled, << will insert a here document skeleton. This is enabled by default. You can disable it with a hook, such as: (add-hook 'sh-...
user avatar
  • 19.4k
13 votes

.bash_profile or .bashrc for shell in emacs?

In addition to the points made by @pingi, you can also use a separate configuration file that will be loaded only for the emacs shell (M-x shell): From the manual page (emacs) Interactive Shell: ...
user avatar
  • 20.4k
12 votes
Accepted

"cannot set terminal process group" error when running bash script

The -i flag requests that Bash run in interactive mode, which requires a terminal. The solution is to leave the shell-command-switch variable at its default value, which is just -c. If you really ...
user avatar
  • 5,520
12 votes

How to fix "Symbol's function definition is void: org-babel-get-header"

According to https://lists.gnu.org/archive/html/emacs-orgmode/2015-11/msg00425.html ob-sh was renamed ob-shell in org 8.2 ... and I cite from there: org-babel-get-header was removed in 0d000f5 (...
user avatar
  • 30.4k
11 votes

Tramp: Waiting for prompts from remote shell

I had this exact same problem but it had nothing to do with RVM on ( which I also have ) on my Ubuntu-16.10 machine. It was related to by custom prompt (PS1) The issue was the prompt PS1. This fix :...
user avatar
  • 111
11 votes
Accepted

Help me avoid "|| true" in org babel bash statements

You're nearly there; you have a :prologue set, via exec 2>&1, to capture both stdout and stderr. To finish this, you just need two things: :results: output to inform Babel that you want the ...
user avatar
  • 835
10 votes
Accepted

Set indentation for shell script function

Setting sh-basic-offset to the required indentation is what is needed - but what I didn't realise is, it's also necessary to close and reopen all shell script files before the customisation takes ...
user avatar
9 votes
Accepted

copy from shell and paste in terminal-emacs

You can't copy-paste between Emacs and a shell without using a system-wide copy-paste facility. Text terminals in general do not provide a copy-paste facility. It seems that you're running this ...
user avatar
9 votes
Accepted

flycheck/bash - i'd like to declare that the next line was intentional

Thanks J David for forcing me to look more deeply. flycheck.el defines sh-bash, the checker used for bash; and that has a next-checker known as sh-shellcheck. Ans, as Jordon is points out, that ...
user avatar
  • 576
8 votes

Emacs can't find Node when Node was installed using NVM

Best solution: Install exec-path-from-shell. From the documentation, after calling (package-initialize), add the following to your .emacs file: (when (memq window-system '(mac ns x)) (exec-path-...
user avatar
8 votes
Accepted

How to get the PATH from the SHELL

No, you don’t want to use -i because you’re not launching an interactive shell. That is, this shell will not be connected to a terminal that the user can type in. It is instead going to be connected ...
user avatar
  • 12.1k
6 votes
Accepted

how to set environment variables={EDITOR, VISUAL} to prefer running emacs?

Although it is not clearly documented in its man page, emacsclient doesn't seem to accept a full command (i.e. program + arguments) as the alternate editor, only a program. You could write a small ...
user avatar
6 votes
Accepted

Spawn a bash outside emacs?

Because bash it is not the GUI program. Start your terminal emulator instead like (start-process "xterm" nil (executable-find "xterm"))
user avatar
  • 2,185
6 votes
Accepted

How can I open an org file at a specific header postion via a command line?

Perhaps something along the following lines: emacs -Q --eval='(progn (find-file "/path/to/file") (goto-char (org-find-exact-headline-in-buffer "org-headline")))'
user avatar
  • 1,106
5 votes

Tramp: Waiting for prompts from remote shell

It looks like you've run the exec-path-from-shell from a Tramp buffer, so when it runs the shell, it attempts to do its magic on the remote server and then set the environment variables in your local ...
user avatar
  • 2,781
5 votes

Flycheck gives errors, when I use shellcheck as linter for bash scripts

apt installs an old version of flycheck, https://github.com/koalaman/shellcheck/issues/704 that does not support --external-sources, this particular commit has been merged at flycheck recently https://...
user avatar
  • 364
5 votes
Accepted

How to get bash source code blocks to execute .profile / .bashrc

You can find out how your code is executed by checking ob-shell.el. As for your particular example, your code is passed to bash as stdin, something like the following $ echo 'echo $...
user avatar
  • 13.7k
5 votes
Accepted

How do you run Emacs on mac?

Just to expand on @ghoetker's answer: Install Emacs into your application folder from https://emacsformacosx.com/ Using the terminal, open the file ~/.zshrc in your favorite text editor. Somewhere ...
user avatar
  • 166
5 votes
Accepted

eshell should use bash_aliases

eshell should not use your bash aliases because, other than them both being shells, eshell has nothing to do with bash. eshell is a shell written entirely in elisp. It's not bash, sh, ksh, csh, zsh, ...
user avatar
  • 43.8k
4 votes
Accepted

sh-script alignment issues

For the indentation after the | you should be able to get the right result by going to the incorrect line (i.e. the one that starts with grep) and then do M-x smie-config-set-indent RET before "|" RET ...
user avatar
  • 25.4k
4 votes

Set indentation for shell script function

I set-basic-offset to 2 but that didn't seem to work, I went back pressed C-h v sh-<TAB> and realized that there was a sh-indentation I set that variable to 2 and everything seems to work like a ...
user avatar
4 votes

Highlighting shell variables within quotes

I improved @Lindydancer's answer in the following ways: Inlined the sh-script-extra-font-lock-is-in-double-quoted-string function, as it was only used once Escaping the variable works. Numeric ...
user avatar
  • 307
4 votes

flycheck/bash - i'd like to declare that the next line was intentional

The only way you would get that error is if you were using the shellcheck checker, in order to remove these warnings you need to customize the command flycheck is using for shellcheck, there is no ...
user avatar
4 votes

How do you run Emacs on mac?

Yes. An alias to the binary within Emacs.app is useful and will allow to call an up-to-date version of emacs from the terminal via “emacs”. I have the following set up alias emacs='$(/Applications/...
user avatar
3 votes

how to set environment variables={EDITOR, VISUAL} to prefer running emacs?

emacsclient has a -a option which lets you specify an alternate editor to use if there is not an emacs process with a running server. So emacsclient -a emacs may do what you want. The alternate ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible