Skip to main content

Questions tagged [shell]

Question about the functionality that let Vim interact with shell command typically triggered Cia the :! command.

Filter by
Sorted by
Tagged with
1 vote
1 answer
53 views

How to show outputs of a ":!cmd" command on a new screen, rather than at the bottom of my screen?

Whenever I type a shell command, like: :!ls Neovim will display it at the bottom of my screen. I'd like it to, instead, clear the whole window, and display it at the top. Is that possible?
MaiaVictor's user avatar
1 vote
0 answers
40 views

`term_start` fails to have `-m` option for shell like bash when using the shell path to invoke

I uses vim 9.1 shipped with bash 5.2.26(1)-release (x86_64-pc-msys) both installed by git-bash. :h terminal-use says :term will start one "terminal emulator" and ran the job. Then when I ...
An5Drama's user avatar
  • 125
-1 votes
2 answers
76 views

system() without shell

Is there a way to execute a host OS command directly, without spawning a shell that in turn runs the command? Preferably passing an argument list, in execvp() style? For example " hypothetical ...
usretc's user avatar
  • 374
1 vote
1 answer
56 views

Getting buffer name in a shell script

I have a shell script meant to run within vim. I'd like it to insert the name of the file I'm editing but I can't figure out how to do it. Is there a way to, perhaps, call bufname() from within a ...
MDeBusk's user avatar
  • 436
0 votes
1 answer
70 views

Command-line option to dump buffer to stdout upon exit? [duplicate]

Say I do the following in my shell (but where cat is actually another command that does meaningful work with stdin): $ cat | very | long | pipeline typing some input lines here... ^D $ However, my ...
CarmenCarmen's user avatar
2 votes
1 answer
543 views

Using the WSL terminal with Neovim

I have Neovim installed on Windows. I use WSL for running Python and C code. So I'd like to map a key to get Neovim to run a shell command in WSL directly from the Neovim editor. But I seem to be ...
vvenk's user avatar
  • 33
1 vote
0 answers
61 views

How to paste an item selected by external FZF in the cursor position?

I know I can paste output of external shell command with :read! ls. But :read! ls|fzf doesn't work for me. Is there a way for me to go from vim to shell, use fzf to select an item, then go back to vim ...
nabik's user avatar
  • 11
0 votes
0 answers
42 views

Ugly border line after running shell command in Neovim

How to remove this kind of status line that appears after I get result of running shell command in Neovim using exclamation mark (!)? NVIM v0.8.1 with lualine.
Gleb Voitko's user avatar
0 votes
0 answers
58 views

Shell commands in Vim vs. Neovim?

When I run a shell command in Neovim like :!ls the results come up in a little minibuffer. In Vim, the Vim instance is temporarily closed and the results are printed to the terminal without my ...
Vinn's user avatar
  • 781
2 votes
1 answer
45 views

:.w !bash a temporarily modified line and executing it in the shell

#!/usr/bin/env bash # scp /tmp/abc.sh SERVER1:~/bin && ssh SERVER1 "~/bin/abc.sh" echo "Hello Stack Exchange" echo "thanks for the help I would like to be able to use ...
Aaron Burda's user avatar
1 vote
2 answers
2k views

Change default shell to powershell in Neovim

Currently the default shell nvim uses is cmd.exe I tried changing it by setting shell to powershell in my nvim config but that didn't work, so I tried this command in the nvim command line: :let &...
Rohith Nambiar's user avatar
0 votes
2 answers
271 views

Selecting text from shell in neovim

I like to execute my scripts in the shell using :! % But once I do, I can't select the text from the shell in the output. I'm currently using neovim. When I click into the shell to select the text, I ...
pepperdreamteam's user avatar
0 votes
1 answer
110 views

Put word count of lines into variable

I can get a word count of a range of lines, by doing something like this: :1,20w !wc -w (where that gets lines 1 to 20, writes (w) them to the external shell command (!) wc -w, and outputs the result ...
markling's user avatar
  • 389
1 vote
1 answer
137 views

Determine if a bash script is called within vim

Is there a way for a bash script to determine if it's being run from within vim? I'm writing a small bash script that is only useful if called within vim. I'd like to assure that it only does its ...
MDeBusk's user avatar
  • 436
1 vote
0 answers
88 views

set shell = powershell. But I want to use the Anaconda powershell

Is there any way to use the Anaconda powershell instead of the standard Windows powershell? In my .vimrc I have set shell=powershell set shellcmdflag=-command Running on Vim 9 for Windows.
Barzi2001's user avatar
  • 640
0 votes
1 answer
39 views

Setting a filetype for piped input

Is it possible to set filetype when starting vim? I would like to get C highlighting when doing something like: $ echo 'int main(){return 0;}' |vi -R - from a shell. I have tried adding --cmd 'set ...
Petr Skocik's user avatar
3 votes
2 answers
699 views

How to use value under cursor in the shell command?

Is it possible to use word under cursor in shell command? Say: Elvis ^ cursor here then :r! echo <word_under_cursor> and get "Elvis" read in.
l00p's user avatar
  • 263
1 vote
1 answer
449 views

How to recognize Azure pipeline template expressions in bash?

When I work with Azure DevOps pipeline files (yaml), I don't get any syntax highlighting in script or bash blocks: That's why I have installed inkarkat/vim-SyntaxRange and configured it to recognize ...
MaxGyver's user avatar
  • 231
2 votes
1 answer
132 views

Execute a shell command over a visual range with a user input prompt?

In my Markdown notes, I would like to: Select a few lines with V Encrypt those lines, externally, with :!gpg Prompt for a password rather than store it, possibly with input() I tried executing over ...
Luke's user avatar
  • 123
1 vote
1 answer
214 views

What factors control the color scheme in a terminal?

I am trying to use VIM through new "Windows Terminal" app on a Windows 10 operating system. The VIM app is installed inside a debian WSL app. I can't wrap my head around how the entire color ...
Asad Munir's user avatar
1 vote
0 answers
86 views

gVim ':terminal' accents don't work

I am using gVim in Xubuntu 20.04. My version is vim 8.2.4295. If I use a regular terminal, like xterm, and open Vim and then type ':terminal', I can use accents, e.g., íàê, etc. while in the vim-...
Carlos's user avatar
  • 11
1 vote
0 answers
34 views

False indentation after line continuation in if-else clause for `sh` filetype

I have shell script file (filetype=sh) like if [ -f filename ]; then echo "file exit" | \ cat - else echo "file not exist" fi When I select the block and apply ...
auditory's user avatar
  • 170
1 vote
0 answers
544 views

How to view the full shell error from a vim script?

I have been using vim/nvim for years on my desktop, and one of the most useful libs I have is the FZF vim plugin, specifically the command that lists the tags from the current buffer: :BTags [QUERY]: ...
abbood's user avatar
  • 743
0 votes
1 answer
43 views

Help in troubleshooting strange behavior when resuming Vim from background

Latest update I start to think that the problem is not due to Vim in the first place. See this. Previous update I think I've almost tracked it down. The issue seems to be due to either command-t or ...
Enlico's user avatar
  • 2,224
1 vote
0 answers
86 views

How to customize how neovims "shell command buffer" is shown?

I am wondering about the behavior of the buffer that appears in the bottom of the terminal when running a shell command in neovim. How can I make it appear the right side instead? How can I make the ...
mama's user avatar
  • 123
1 vote
0 answers
50 views

How can I launch interactive terminal programs in neovim just like I can do in vim? [duplicate]

I'd like an easy way to switch from neovim to vim for the reason of, some plugins are not compatible with neovim (Ultisnips). I hope'd I could just run :!vim however that doesn't work - errors appear: ...
Chris Stryczynski's user avatar
2 votes
2 answers
2k views

Make `!` work with powershell (neovim)

I want to use ! with powershell. I use neovim natively on windows. I tried these settings set shell=powershell.exe set shellcmdflag=-NoProfile\ -NoLogo\ -NonInteractive\ -Command set shellpipe=| set ...
eyal karni's user avatar
  • 1,136
2 votes
2 answers
170 views

Make `%!` work in windows

I am on windows natively with neovim-qt . I tried to use %!python -m json.tool on a valid json file . It says Expecting value: line 1 column 1 (char 0) . In powershell : cat .\graphs.json | python -m ...
eyal karni's user avatar
  • 1,136
1 vote
0 answers
86 views

Using inline cmdline expressions in windows

I wondered if I could use inline cmd expression like in the example :args ``find -iname *.py`` So, I wanted to either use WSL expressions(same as above) or powershell (Get-ChildItem C:\temp | Select-...
eyal karni's user avatar
  • 1,136
2 votes
1 answer
660 views

How can I create a shortcut that saves the file and executes a sequence of shell commands?

I know that I can create shortcuts on a vimrc file like the following: :map <C-W> :w<CR> However, let's say I have some different commands that I can execute on my shell: notify-send &...
raylight's user avatar
  • 545
0 votes
1 answer
105 views

Shell script runs multiple times, I want it to run only once

I use vim pretty extensively for latex compiling. I've a function which automatically compiles the current tex file. I use pdflatex as a compiler, which creates a bunch of different files that it ...
nikinbaidar's user avatar
0 votes
2 answers
768 views

how to run a shell command in the same shell process that vim was started

I want to source a file in the same shell process vim was started, from within vim as an ex command. As far as I know, vim creates a new subshell and run commands. In addition to that, If I source a ...
Ali's user avatar
  • 151
3 votes
1 answer
2k views

Using the execute shell command (:!) on Windows and MSYS2

I'm new to neovim (and vim in general), and I'm trying to use it on Windows with MSYS2. I noticed they have a package for vim, but not for neovim. I used the neovim installed through chocolatey ...
Bodhi Daruma's user avatar
1 vote
1 answer
58 views

Issue with makeprg Shell Script $? Variable

I have the following .vimrc: let &makeprg="./run-tests" The contents of run-tests: #!/bin/sh error_file=$(mktemp) coverage run --source "$PWD" --branch -m pytest tests/ >&...
Edward Chamberlain's user avatar
0 votes
1 answer
304 views

Vim8 && in :terminal's [command]

When running the vim command :!echo A && echo B the result is as expected A B Press ENTER or type command to continue However when I try to do the same thing with the new integrated terminal ...
Fraser's user avatar
  • 103
0 votes
2 answers
77 views

How to execute a shell script from a line in a file with `%` in it

I have a shell script on a line alone in a file which I would like to be able to easily execute from vim. Normally I could simply use Y:!^R", but this particular script has % in it, which is ...
Iiridayn's user avatar
  • 193
8 votes
3 answers
1k views

See what Vim `:!` executes

Between :%! exe "!..." exe "!bash -c" shellescape(...) I'm getting quite confused as to what exactly Vim invokes. And I suspect at some point it invokes bash -c bash .... Is ...
usretc's user avatar
  • 374
1 vote
3 answers
328 views

How can I open a file, edit it and save its output to a shell variable?

I know that I can open a file through a pipe with vim with the following command: cat myfile.txt | vim - I also know that I can edit files on vim directly from the command line as the following: vim -...
raylight's user avatar
  • 545
2 votes
2 answers
855 views

How to execute shell command and show result right inside vim similar to when execute command through autocmd?

The main objective of this question is I want to get the shell command's execution result to show in small split window right inside vim while I'm editing the file; the same result I would get when I ...
haxpor's user avatar
  • 121
0 votes
0 answers
1k views

"Inappropriate ioctl for device" and "no job control in this shell" bash error

I am getting a bash|1 warning| Inappropriate ioctl for device when Ale runs lint on cpp files with gcc/g++. Using gcc/g++ to compile manually in the terminal works fine. Otherwise the linting of cpp ...
Tiseno's user avatar
  • 1
11 votes
1 answer
2k views

Why is it not possible to kill Vim using the TERM signal from inside Vim itself?

Out of curiosity, I tried to kill Vim from inside vim --clean. I tried: :!kill $PPID :call system('kill ' . getpid()) However, nothing happens after running the commands above. The commands give no ...
Flux's user avatar
  • 1,061
7 votes
1 answer
2k views

How to color VIM ":!{cmd}" output?

I'm trying to get the same setup as the guy in this video, so that when :!pytest % gets called, the output is colored. I've tried with various vanilla colorschemes, with no luck... I'm using Neovim, ...
eltbus's user avatar
  • 181
2 votes
2 answers
138 views

How to turn this piped bash command into a vim map?

I have a bash command that will align text into a tabular form. If I have input such as this: A | B | C Alpha | Beta | Gamma 12 | 34.56 | 78.9 I can run cat test.txt | sed -e 's/|/'$'\001''|/g' | ...
Roxy's user avatar
  • 177
0 votes
1 answer
322 views

Can't use the usual !!foo in vim // gvim on Windows 10 - missing tmp files

I'm running vim // gvim 8.2 (fresh off of vim.org, and was before---just re-installed to do so as administrator, per instructions I'd missed before). I've been getting this since getting this Windows ...
GTbrewer's user avatar
2 votes
1 answer
357 views

How to pass custom arguments to the shell invoked by :terminal?

I would like to specify the startup command to run on the :terminal shell. E.g. bash -c ls. The shell can be specified with set shell=bash, but how to specify the arguments? In another use case, I ...
tejasvi's user avatar
  • 470
0 votes
1 answer
1k views

Send command to :terminal buffer in Vim?

I used :term to open a new integrated split terminal window. The problem is, using :! <cmd> opens a new buffer which takes the entire screen, runs the shell command, then waits for me to press ...
daedsidog's user avatar
  • 153
0 votes
1 answer
107 views

Shell syntax, how to patch bad highlight groups

The neovim syntax for shell scripts doesn't check if keywords like echo, done, exit etc.. are surrounded by blank spaces or if they're part of a bigger Word. This results in the following bad ...
noibe's user avatar
  • 189
2 votes
1 answer
245 views

Is there a filetype in Vim when opening the a file containing output/errors from g++ so that I can see those files with the original coloring?

Sometimes, when faulty outputs from compilations of C++ files/projects are to long, I like to redirect that output to a file, so that I can inspect it side-by-side with each of the offending files in ...
Enlico's user avatar
  • 2,224
2 votes
1 answer
2k views

Vim function : how to expand vim variable in shell command?

I'm trying to write a vim function to update ctags and cscope databases. I'm trying to save the vim variable projectRoot in environment variable then expand this enviroment variable in the find ...
Salahuddin Ahmed's user avatar
0 votes
1 answer
95 views

Running Vim in shell script opens rest of shell script in a buffer

I've got Vim starting in a shell script to install some plugins. I'm using nvim --headless +PlugInstall +qall, but when Vim opens, it has the rest of the shell script (cd $HOME/.config/coc/extensions &...
twlscnds's user avatar
  • 103