Skip to main content

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
2 answers
347 views

How to tangle code blocks from an org file, compile the output, and open the result, with a single command?

I use org-babel-tangle to generate lilypond and latex documents from org files. These org files have the following first line: #+PROPERTY: header-args :LANG :comments org :tangle PATH/FILE_NAME.EXT ...
crocefisso's user avatar
  • 1,479
0 votes
0 answers
90 views

Executing highlighted code snippet

I login to a computer with SSH. In my home directory, there is a file called test.sh with a bunch of BASH code in it. I start editing it with emacs -nw test.sh. It is a large file, and I want to test ...
Dante Picchioni's user avatar
1 vote
1 answer
61 views

How to print bash results properly?

When I do $ tree -d -L 3 /usr/share/emacs/28.2/lisp in a bash terminal I get: /usr/share/emacs/28.2/lisp ├── calc ├── calendar ├── cedet │   ├── ede │   ├── semantic │   │   ├── analyze │   │   ├── ...
crocefisso's user avatar
  • 1,479
0 votes
0 answers
78 views

How to stop screen from changing how emacs handles colors

In .screenrc, I have this line: term xterm-256color If I do not use that, or if I try something different (like xterm-color or screen-256color), then emacs has absolutely no color. Here is a font-lock ...
Ness's user avatar
  • 187
0 votes
1 answer
38 views

How to define a function to add the text "hello world\n" at the current buffer's cursor? [duplicate]

Looking for this for years. I am going to be brave and ask. (defun paste-hello-world () (paste-raw-text-at-cursor "hello world\n") ) Need something like the above. The place I work at ...
Matthaeus Gaius Caesar's user avatar
0 votes
2 answers
2k views

How do I use Emacs editor in Git Bash terminal on a Windows machine?

I am currently using vim editor on Git Bash terminal running in a Windows machine, but I want to switch over to Emacs editor. It is returning bash: emacs: command not found . Do I need to install the ...
Amah N. Lofty's user avatar
0 votes
1 answer
90 views

org-babel Bash Results in RESULTS

Often when I issue a bash command, the results opens in a popup buffer, instead of going into the RESULTS drawer. F.ex this command. #+begin_src shell nc -w 2 -v -z danzinger 8507 #+end_src It opens ...
Jason Hunter's user avatar
0 votes
0 answers
93 views

bash script fail execute in org-babel block

Below bash script works as a bash script but if execute it in org-babel block as below, it report error: sh: 2: Bad substitution code: #+begin_src sh :results output str="toto.titi.12.tata.2.abc....
lucky1928's user avatar
  • 1,724
0 votes
1 answer
81 views

How can I suppress specific flycheck messages in sh-mode?

In sh-mode I am getting following flycheck-error message: File Line [v]ColLevel ID Message (Checker) config.sh 2 error Syntax error: "(" unexpected (sh-posix-dash) ...
alper's user avatar
  • 1,460
1 vote
1 answer
49 views

Why does the same code called first by bash and then by emacs not behave the same way?

I have this LaTeX code: %% test.tex \begin{wrapfig} \includegraphics[width=1cm]{fig1.eps}\end{wrapfig} \includegraphics[width=1cm]{fig2.eps} I have a script called fix-files-ext.sh that fixes the ...
Onner Irotsab's user avatar
1 vote
1 answer
1k views

How to run yarn in a bash script from emacs?

I have a bash script like this: #!/bin/bash cd ~/src/program && rm -rf node_modules && yarn When I invoke this script by executing (shell-command "bash ~/src/helper/script.sh&...
Evgeny Mikhaylov's user avatar
0 votes
1 answer
135 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 ...
Iakov Davydov's user avatar
1 vote
1 answer
227 views

Why are Emacs Eshell and macOS default terminal showing different results for the same query on a program (SDKMAN) version?

I am using Emacs (config file) on macOS Monterey (12.5). There is something that I do not understand. After being queried on a specific version of the program called sdkman sdk, eshell and macOS ...
Pedro Delfino's user avatar
2 votes
2 answers
90 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 ...
Paul's user avatar
  • 223
4 votes
1 answer
808 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 &...
Quasar999's user avatar
0 votes
2 answers
268 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)...
buhtz's user avatar
  • 749
1 vote
1 answer
634 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 ...
alper's user avatar
  • 1,460
1 vote
1 answer
58 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 ...
alper's user avatar
  • 1,460
0 votes
1 answer
132 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 $@ ...
Enze Chi's user avatar
  • 1,470
2 votes
2 answers
973 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 ...
Webdev Tory's user avatar
3 votes
2 answers
587 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 ...
kipkipe's user avatar
  • 143
6 votes
1 answer
3k 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, (...
Arch Stanton's user avatar
  • 1,777
6 votes
2 answers
398 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 ...
isamert's user avatar
  • 113
0 votes
2 answers
291 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:[email protected]#2221: :END: #+...
kidmose's user avatar
  • 253
0 votes
0 answers
115 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 ...
Declan Thompson's 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 ...
RichieHH's user avatar
  • 880
1 vote
2 answers
553 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 ...
marc.soda's user avatar
  • 133
0 votes
1 answer
558 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 | ...
tinlyx's user avatar
  • 1,384
2 votes
1 answer
477 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 ...
ch-pub's user avatar
  • 252
2 votes
1 answer
118 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 ...
User12345's user avatar
  • 145
0 votes
2 answers
274 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 ...
Tian's user avatar
  • 288
0 votes
2 answers
206 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 ...
Welgriv's user avatar
  • 67
0 votes
0 answers
142 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....
spacegoing's user avatar
1 vote
0 answers
59 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 ...
dara's user avatar
  • 11
0 votes
1 answer
332 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 ...
Shep's user avatar
  • 103
0 votes
2 answers
380 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* ((...
Aaron's user avatar
  • 1
0 votes
1 answer
542 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 ...
HaPsantran's user avatar
2 votes
2 answers
1k 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 ...
menuhin's user avatar
  • 335
1 vote
0 answers
118 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
Veera's user avatar
  • 315
0 votes
1 answer
372 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 ...
RaGa__M's user avatar
  • 101
2 votes
1 answer
1k 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` ...
muhuk's user avatar
  • 163
7 votes
5 answers
23k 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?
eugene's user avatar
  • 529
1 vote
0 answers
120 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 $( ...
kdb's user avatar
  • 1,591
3 votes
2 answers
2k 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. ...
Ness's user avatar
  • 187
3 votes
1 answer
111 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 "...
LeGLL's user avatar
  • 33
1 vote
2 answers
86 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 ...
Chris Stryczynski's user avatar
7 votes
1 answer
504 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, ...
american-ninja-warrior's user avatar
1 vote
0 answers
32 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 ...
Erik Bennett's user avatar
4 votes
1 answer
156 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 ...
Trey's user avatar
  • 925
1 vote
1 answer
332 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 [ “$?”...
Eric Hansen's user avatar