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-...
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 .....
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 ...
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 ...
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-...
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:
...
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 ...
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 (...
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 :...
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 ...
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 ...
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 ...
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 ...
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-...
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 ...
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 ...
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"))
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")))'
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 ...
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://...
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 $...
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 ...
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, ...
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 ...
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 ...
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 ...
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 ...
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/...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
bash × 90shell × 17
org-mode × 8
org-babel × 7
microsoft-windows × 6
emacsclient × 6
ansi-term × 6
indentation × 5
tramp × 5
shell-mode × 5
eshell × 4
flycheck × 4
term × 4
environment × 4
zsh × 4
osx × 3
shell-command × 3
ubuntu × 3
spacemacs × 2
evil × 2
debugging × 2
git × 2
terminal-emacs × 2
start-up × 2
process × 2