Questions tagged [bash]

Bash is the `Bourne again Shell`, one of the more common Unix shell languages. This tag should be used for questions about editing bash scripts in Emacs, or writing bash scripts that invoke Emacs themselves. This tag doesn't necessarily apply to questions about running a shell in Emacs (which may use a language other than Bash), for which other tags are available.

Filter by
Sorted by
Tagged with
0
votes
2answers
25 views

Unable to find files with ssh and environment variables

I have installed exec-path-from-shell as well as included the following in my init.el (when (memq window-system '(mac ns x)) (exec-path-from-shell-initialize)) within my ~/.bash_profile I have ...
0
votes
2answers
46 views

Modify environment using a bash script of an already running emacs

I have Emacs open with lots of files. I want to compile within Emacs, but first I have to source some setup.sh bash script that modifies the environment. How do I do that? This post says it's ...
0
votes
0answers
29 views

GUI started emacs has different env vars than terminal started one

I wrote LD_LIBRARY_PATH both in .bashrc and .bash_profile. However, if I started emacs in terminal using emacs, LD_LIBRARY_PATH is shown in getenv. If I started it using GUI, there is no such variable....
1
vote
0answers
35 views

How can I get an ftp connection to stop timing out in emacs?

I'm using M-x shell in Emacs and just connecting through vanilla ftp from the command line (bash). I remember (many moons ago) I came across a script for Emacs that'd keep a persistent ftp connection ...
0
votes
1answer
29 views

How to make emacs recognize a bash script that ends in .sh? [duplicate]

I'm trying to get Emacs to understand that my script is bash. I tried adding -*- bash -*- to the first line of the file, but it still opens in Shell-script[sh] mode. I can rename the file to give it ...
0
votes
1answer
39 views

How to pass arguments to a shell script using `make-process` function?

Consider a script file: ~/project/script.sh echo "arg 1 $1" echo "arg 2 $2" echo "arg 3 $3" And elisp file that invokes it using make-process: ~/project/special-mode/special-mode.el (let* ((...
0
votes
1answer
92 views

Working Around the OS X Catalina Conflict with Emacs 26.3

I'm struggling to workaround the problem discussed in this post. I'm working through the accepted solution (which also references this post, and getting what I think is close, but not quite there. The ...
2
votes
2answers
149 views

Preload problem: Emacs as daemon in X

Background: I want to use emacs like tmux which can run as persistent session as well as shorten the time for me to start bringing up emacs when I want to (as inspired by these: Emacs and a Tmux ...
1
vote
0answers
55 views

How to pass bash commands from a script to terminal?

Let's say I have a bash script. Is there a way I can pass specific lines or blocks in the script to terminal process in EMACS? Just like how we do for R script using command C-c R
0
votes
1answer
70 views

Creating ctag DB gives “permission denied” error on git-bash (MS Windows)

I am a Linux user (world was pretty neat; less to no headache)-- I've been using vim with cscope to wade through huge code-base....... And for some reason, now I have to use windows machine, here are ...
2
votes
1answer
156 views

How to set up emacsclient as default editor on Debian?

What am I trying to achieve I want to use emacsclient (not emacs) as my default text editor on Debian Buster. What have I tried so far Alternatives: > sudo update-alternatives --config editor` ...
1
vote
0answers
57 views

sh-mode: Correctly indent and highlight inside bash's subshell substitution $()?

I noticed that bash will correctly apply syntax highlighting inside the subshell substitution in VALUE="Hello $(echo World)." But when creating a more complicated value, e.g. VALUE="Hello $( ...
0
votes
0answers
19 views

(comint-magic-space) in Eshell

I like to interact with the history of my bash commands. For instance, !?python would run the last command that contains python. Since the outcome is quite unpredictable, I often expand it before ...
1
vote
1answer
344 views

How to change shell-script-mode indentation not to use tabs?

To reproduce my issue, open your .bashrc or a .sh file and type the following: if while echo The if has no indentation. Good. The while has the default four spaces of indentation. Good. ...
3
votes
1answer
72 views

Spawn a bash outside emacs?

I am trying to spawn a shell outside emacs, not in a buffer. I have tried (start-process "firefox" nil "firefox"), wich does start a firefox process outside emacs, but when i tried (start-process "...
1
vote
2answers
57 views

How can I get the list of recentf files from bash / cli?

How can I retrieve the list of recent files in bash? I'd like to get this set of files so I can use it with rofi. I could manually parse the data file that looks something like: ;;; Automatically ...
5
votes
1answer
127 views

Help me avoid “|| true” in org babel bash statements

I'm writing a lot of manuals on how to accomplish things in bash. Often I'm showing people something that doesn't work, and then go on to show what works. When I'm showing something that doesn't work, ...
1
vote
0answers
26 views

mmm-mode strange behavior with perl-shell-script

Background: I've been working with a program that is about half Bash and half perl. I thought I'd give mmm-mode a try since it sounded like just the mode for me. I don't know lisp well enough to be ...
4
votes
1answer
100 views

sh-script-mode: get [[ … ]] pair expansion to automatically include whitespace?

Say you're coding a shell script and you want to write something like: if [[ "$out" =~ 'none' ]]; then return $err fi If you're just typing it out and have any of the various electric/pair ...
1
vote
1answer
66 views

How do I specify a daemon to start with alternate emacs version with emacsclient

I have found this script from here #!/usr/bin/env zsh # Checks if there's a frame open emacsclient -n -e “(if (> (length (frame-list)) 1) ‘t)” 2> /dev/null | grep t &> /dev/null if [ “$?”...
2
votes
2answers
230 views

How to run selected bash commands

I have a large bash script and I need to rerun certain lines of code. Normally I would comment out any line I don't want to run and then execute the file on the shell. But that is rather cumbersome. I'...
1
vote
2answers
103 views

eShell Aliases – How to `grep` Forward Slashes

In Bash, I have an alias of ls -Ap | grep --color=always /$ that grabs the directories of the current directory, more or less. That said, using the same as an alias in Emacs's eShell seems to not ...
1
vote
1answer
49 views

Making Emacs show the last part of bash-command output

I use the Evil mode inside Emacs for doing a lot of my work. If I need to run a shell-command and see its output all I need to do is type in normal mode :!<bash command>. The window splits into ...
2
votes
1answer
738 views

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

I don't understand how the source code blocks work exactly. There are some variables, definitions and aliases in my .bashrc that I think I should be able to use in the source code blocks. However, ...
1
vote
1answer
403 views

Emacs opens gitbash in new system window

I've try to follow this question and sulution Git Bash in emacs on Windows I have this function: (prefer-coding-system 'utf-8) (defun git-bash () (interactive) (let ((explicit-shell-file-name "C:/...
1
vote
1answer
588 views

M-x shell from MSYS2: cannot set terminal process group

I'm using MSYS2-x86_64, and whenever I do M-x shell I see the following: bash: cannot set terminal process group (-1): Inappropriate ioctl for device bash: no job control in this shell ]0;~/.emacs.d ...
3
votes
1answer
55 views

completion for .bash_history

I am considering implementing an ivy-powered bash_history greper for term-mode, but before I do I wanted to know if this has already been done, by some fancy company-bashhistory package or whatever. ...
1
vote
1answer
182 views

Set custom bashrc or PS1 variable

I'm using, at the terminal on my android device, an simple approach to show the path to my location (export PS1="(\w)$ "). However, the \w seems to not be working in emacs shell emulator running ...
1
vote
1answer
207 views

How to turn off line wrap when opening from terminal

I'm trying to open a file from terminal and ensure that line-wrap will be off. I'm trying the following code, but it won't work emacs --no-window-system --eval '(setq truncate-lines 1)' file I don't ...
4
votes
2answers
141 views

How to sort bash functions alphabetically?

My boss is a bit of a neat freak. He wants the functions in my functions.sh be ordered alphabetically. foo() { echo foo } baa() { echo baa } So baa should appear first in the file. Can emacs ...
1
vote
1answer
84 views

Eshell simple echo in parenthesis not working

Why doesn't the following work in eshell $ (echo "foo") Symbol's function definition is void: echo What I tried: googled eshell parenthesis not working More Context: Eventually I'm trying to ...
1
vote
0answers
191 views

notmuch doesn't show INBOX (“Spawning child process: Invalid argument”)

I'm trying to get notmuch working on Windows 10 using WSL/Ubuntu. The idea is to treat the WSL as a remote machine (roughly following https://notmuchmail.org/remoteusage/) and to have a shell script ...
1
vote
1answer
704 views

How do you abort an emacs M-x compile compilation

How do you abort an emacs M-x compile compilation? I'm editing a bash file, and I "test execute it" by doing M-x compile. What I tried - googled:emacs abort compilation The file I'm working on is ...
1
vote
1answer
143 views

How can I tail/stream output when evaluating org babel shell blocks?

I learnt about asynchronous execution of org babel shell code blocks, thanks to: How is #+BEGIN_SRC sh :results drawer different to #+BEGIN_SRC sh I want to know if it's possible to tail/stream the ...
7
votes
1answer
3k views

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

How do you trouble shoot this? (trying to run a sh block async) #+BEGIN_SRC sh /tmp/7.sh ...
1
vote
0answers
311 views

How is #+BEGIN_SRC sh :results drawer different to #+BEGIN_SRC sh

While reading http://www.howardism.org/Technical/Emacs/literate-devops.html I saw the author recommending #+BEGIN_SRC sh :results drawer for "time-consuming and verbose" commands. (I do a ...
5
votes
1answer
1k views

Remote shell path - env: No such file or directory

In Emacs, when I open the file /ssh:USER@HOST:/PATH, Tramp mode kicks in and everything is great. While editing the file, I want to open a remote shell as well using M-x shell, but its behaviour is ...
1
vote
1answer
353 views

Git bash opens in window outside of emacs

When running Emacs on Windows 10, I am able to launch git bash from within Emacs using the information given here, here, or here. For example, I can just add these two lines to my .emacs: (setq ...
0
votes
0answers
31 views

How to make compile function obey my .bashrc when compile is called by some library?

In my ~/.bashrc I've got some changes, the most important one being the change to $PATH. One of the commands I'm using runs through the compile function, but it fails - bash can't find the binary. ...
3
votes
1answer
834 views

Run Emacs command from terminal and terminate

Is there a way to open a file on emacs, execute a command and quit, quietly? I tried emacs file --eval '(progn (cmd) (kill-emacs))' But if I execute this, emacs shows up briefly before quitting. Is ...
4
votes
1answer
705 views

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

I use GNU Emacs 26.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.18.9) of 2017-06-09, and Shellcheck 0.3.7 als linter for bash scripts (https://www.shellcheck.net). When I open a bash script, I ...
3
votes
1answer
2k views

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

I've got Node installed using NVM, and Emacs (v25.2.1) isn't able to find Node. When I run M-: (executable-find "node") I get back nil. However, when I run M-: (executable-find "cat") I get "/bin/cat"...
1
vote
1answer
150 views

Suspend frame, run a bash command, sleep for a few seconds and come back to emacs

[ I'm using the latest emacs, and always emacsclient with the -nw option in a terminal ] I have this workflow I want to "automate" with an emacs hotkey. I find myself doing this over a hundred times ...
1
vote
2answers
418 views

tramp and fish shell (local)

How to setup emacs tramp to open remote files while local shell is fish? More precisely is how to ask tramp to use bash shell instead of one named in SHELL environment variable?
1
vote
1answer
719 views

Linter for Google shell style guide?

Does anyone know of a Bash linter for the Google shell style guide? I have been using shellcheck as my linter with flycheck but it doesn't conform to this standard.
0
votes
1answer
876 views

Ansi-Term not reading .profile

my question is very similar to this one. I use my .profile file to set environment variables, such as EDITOR. However, when I run ansi-term and type printenv I can see that that variable is not ...
3
votes
0answers
747 views

Using Windows bash as the shell

I'm trying get Spacemacs (i.e., Emacs) to use the Windows subsystem for Linux bash shell as the shell. I've added (setq explicit-shell-file-name "c:/Windows/System32/bash.exe") to my .spacemacs ...
0
votes
1answer
315 views

External command doesn't run in GUI mode

I have the following function attached to f2 key in latex mode: (defun latex-compile () "Runs pdflatex on current file" (interactive) (let* ((file-name (shell-quote-argument (buffer-...
0
votes
1answer
140 views

Garbage prepended to PATH

For some reason, some garbage is prepended to my PATH variable in emacs. Testing from eshell: (M+x eshell): ~/projects/rust/logentries-parser/src $ echo $PATH bash: cannot set terminal process group ...
1
vote
0answers
412 views

ansi-term changes in line-mode not registered after char-mode

Here's the situation. I start M-x ansi-term, which launches it in term-char-mode. I type the following: echo "hello world" and press RET, which outputs on the next line the expected output hello ...