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
1 answer
14 views

How to run initialization commands with tramp?

I would like to run some commands on remote host before giving control to tramp. E.g., I would like to load easybuild modules to make sure that environment variables are set correctly for ESS. My ...
user avatar
0 votes
2 answers
39 views

Can emacs handle bash extglob case patterns properly?

This question is in two parts: How to cause emacs linter to recognize an extglob expression as an ability instead of a syntax error? How to cause emacs indenter to recognize an extglob expression as ...
user avatar
  • 143
1 vote
0 answers
44 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
2 answers
76 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
  • 569
0 votes
1 answer
147 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,076
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,076
0 votes
1 answer
40 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,340
0 votes
2 answers
263 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
221 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,414
3 votes
1 answer
148 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
  • 81
0 votes
2 answers
107 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
29 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
17 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
  • 758
0 votes
2 answers
265 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
272 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
  • 928
2 votes
1 answer
273 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
  • 210
2 votes
1 answer
59 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
132 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
86 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
78 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
50 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
130 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
217 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
478 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
555 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
100 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
178 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
778 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
4 answers
7k 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
  • 365
1 vote
0 answers
106 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
2 answers
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
89 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
63 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
339 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
125 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
  • 835
1 vote
1 answer
175 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
523 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
  • 489
1 vote
2 answers
231 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
106 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
646 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
  • 661
1 vote
1 answer
969 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
210 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
432 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
230 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
148 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
212 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