Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

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
1 vote
0 answers
25 views

mingw shell in emacs

i'd like to use bash shell from msys2 in emacs and i made the following changes in emacs init file: (setq explicit-shell-file-name "C:/tools/msys64/usr/bin/bash.exe") (setq shell-file-name &...
user avatar
0 votes
1 answer
42 views

eshell should use bash_aliases

I want my eshell to use ~/.bash_aliases. But it seems that it doesn't because my usual aliases do not work. This is my full minimal config using use-package: ;; === Package setup === (require 'package)...
user avatar
  • 499
0 votes
1 answer
97 views

Server bash-ls starting exited with status exit

I keep seeing following error when I run emacs daemon. Server bash-ls:7089/starting exited with status exit(check corresponding stderr buffer for details). Do you want to restart it? (y or n) When I ...
user avatar
  • 1,112
1 vote
1 answer
36 views

emacs 28.0.50 `sh-quoted-exec` has different coloring for `sh` and `bash`

In Shell-script[bash] mode, coloring differs for sh-quoted-exec in #!/bin/sh and #!/bin/bash. If #!/bin/sh is the first line: // I prefert this If #!/bin/bash is the first line: Would it be possible ...
user avatar
  • 1,112
0 votes
0 answers
25 views

translating bash functions to eshell

Try to move to eshell and I am wondering what the best solution to translating the bash functions like below to eshell? function cm-gen { cmake -B build -S . -DCMAKE_EXPORT_COMPILE_COMMANDS=ON $@ ...
user avatar
  • 1,320
0 votes
2 answers
220 views

How to "pipe" a string to a shell command in elisp rather than give it as an arg?

The command I'm trying to duplicate: curl https://example.com | readability https://example.com As far as I can see, though, using that | pipe is NOT the same as passing the string in as an arg. If I ...
user avatar
3 votes
2 answers
184 views

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

I wan't to be able to programmatically open a file in org mode and scroll to a specific header. the file is quite big, so opening the file at a certain place is qhat I am looking for. Any idea how to ...
user avatar
  • 43
6 votes
1 answer
1k views

How to get the PATH from the SHELL

When launched at system start-up, the Emacs daemon doesn't pick up modifications to the PATH introduced by shell initialization scripts. Emacswiki suggests to use this function to update Emacs' PATH, (...
user avatar
  • 1,392
2 votes
1 answer
127 views

Noweb references in sh blocks breaks the syntax highlighting

I use noweb references inside sh code blocks, for example: #+begin_src sh echo "test" <<some-ref>> echo "test" #+end_src But this causes syntax highlighting to ...
user avatar
  • 71
0 votes
2 answers
80 views

Org Babel execute bash via ssh on non-default port; `(wrong-type-argument number-or-marker-p nil)`

Problem In an org file, I have a source code block containing bash code that I want to run on a remote machine: * test :PROPERTIES: :header-args:bash: :dir /ssh:skid@127.0.0.1#2221: :END: #+...
user avatar
  • 243
0 votes
0 answers
26 views

xterm-mouse-mode inserting cursor information on drag

I'm running into a problem with emacs used via ssh. The problem occurs when I: Log in remotely using SSH on Konsole Run emacs -Q Invoke mouse mode with M-x xterm-mouse-mode When I click-and-drag on ...
user avatar
1 vote
0 answers
16 views

Help using compilation-mode or similar to use next-error to navigate bash debug output

Using "set -x" in bash script, outputs each executed command to an ouput file. eg here is part of the bash script #!/usr/bin/env bash # This is called by (my) .xinitrc, xdm and _should_ be ...
user avatar
  • 738
0 votes
2 answers
236 views

How can I re-enable `C-z` in evil mode (to pause Emacs)?

I have been using Emacs for a while and recently started using evil mode. I exclusively use emacs-nox (command line emacs). The only thing that's missing for me is C-z to pause emacs and bring me back ...
user avatar
  • 123
0 votes
1 answer
234 views

How to get the value of a variable inside an org-mode file from command line?

Is there a reliable way to get the value of a variable defined inside an org-mode file from the UNIX shell (bash)? For example, if I have the following inside an org mode file test.org: #+NAME: foo | ...
user avatar
  • 904
1 vote
1 answer
246 views

Bash Environmental Variable Not Recognized

I use Bash for my terminal on Debian. In my .bashrc, I've defined an environmental variable like so: SSH_VAULT_VM="ssh-vault" if [ "$SSH_VAULT_VM" != "" ]; then ...
user avatar
  • 150
2 votes
1 answer
52 views

Using `emacsclient` for `$VISUAL` raises `End of file during parsing`

I want to use emacs as VISUAL with server-mode. As a test, I write the following in a terminal: emacsclient -F "((left . 0) (top . 0))" -c -n file This behaves exactly as expected; it ...
user avatar
  • 145
0 votes
2 answers
108 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 ...
user avatar
  • 288
0 votes
2 answers
76 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 ...
user avatar
  • 67
0 votes
0 answers
75 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....
user avatar
1 vote
0 answers
49 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 ...
user avatar
  • 11
0 votes
1 answer
98 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 ...
user avatar
  • 103
0 votes
2 answers
200 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* ((...
user avatar
  • 1
0 votes
1 answer
473 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 ...
user avatar
2 votes
2 answers
484 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 ...
user avatar
  • 305
1 vote
0 answers
93 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
user avatar
  • 275
0 votes
1 answer
170 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 ...
user avatar
  • 101
2 votes
1 answer
702 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` ...
user avatar
  • 143
4 votes
3 answers
6k views

How do you run Emacs on mac?

I find running the following is different from just running emacs on mac /Applications/Emacs.app/Contents/MacOS/Emacs -nw Should I create an alias in zsh/bash for it?
user avatar
  • 355
1 vote
0 answers
104 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 $( ...
user avatar
  • 1,481
3 votes
1 answer
1k 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. ...
user avatar
  • 145
3 votes
1 answer
87 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 "...
user avatar
  • 33
1 vote
2 answers
61 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 ...
user avatar
6 votes
1 answer
316 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, ...
user avatar
1 vote
0 answers
29 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 ...
user avatar
4 votes
1 answer
119 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 ...
user avatar
  • 815
1 vote
1 answer
170 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 [ “$?”...
user avatar
2 votes
2 answers
509 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'...
user avatar
  • 469
1 vote
2 answers
225 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 ...
user avatar
  • 23
1 vote
1 answer
101 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 ...
user avatar
3 votes
1 answer
1k 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, ...
user avatar
  • 509
1 vote
1 answer
627 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:/...
user avatar
  • 651
1 vote
1 answer
938 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 ...
user avatar
  • 111
3 votes
1 answer
70 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. ...
user avatar
1 vote
1 answer
209 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 ...
user avatar
  • 231
1 vote
1 answer
410 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 ...
user avatar
  • 113
4 votes
2 answers
217 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 ...
user avatar
1 vote
1 answer
146 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 ...
user avatar
1 vote
0 answers
211 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 ...
user avatar
  • 1,429
3 votes
1 answer
1k 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 ...
user avatar
1 vote
1 answer
213 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 ...
user avatar