Questions tagged [shell]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
2 answers
75 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.
user avatar
  • 241
0 votes
0 answers
23 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 ...
user avatar
  • 143
2 votes
1 answer
45 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 ...
user avatar
  • 123
1 vote
1 answer
61 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 ...
user avatar
1 vote
0 answers
47 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-...
user avatar
  • 11
1 vote
0 answers
25 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 ...
user avatar
  • 160
0 votes
0 answers
75 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]: ...
user avatar
  • 549
0 votes
1 answer
21 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 ...
user avatar
  • 1,648
1 vote
0 answers
32 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 ...
user avatar
  • 123
1 vote
0 answers
43 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: ...
user avatar
1 vote
1 answer
261 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 ...
user avatar
  • 1,144
2 votes
1 answer
80 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 ...
user avatar
  • 1,144
1 vote
0 answers
43 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-...
user avatar
  • 1,144
1 vote
1 answer
66 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 &...
user avatar
  • 375
0 votes
1 answer
39 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 ...
user avatar
0 votes
2 answers
119 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 ...
user avatar
  • 51
0 votes
1 answer
377 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 ...
user avatar
1 vote
1 answer
31 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/ >&...
user avatar
0 votes
0 answers
65 views

How to keybind vim to a shell script

I'm new to vim and apologize if the question seems redundant, but I couldn't find a suitable answer. I have a shell script compile.sh that I would like to run each time I press some key (say, F8) on ...
user avatar
  • 1
0 votes
1 answer
91 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 ...
user avatar
  • 103
0 votes
2 answers
51 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 ...
user avatar
  • 173
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 ...
user avatar
  • 335
1 vote
3 answers
87 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 -...
user avatar
  • 375
2 votes
2 answers
224 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 ...
user avatar
  • 121
0 votes
0 answers
450 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 ...
user avatar
  • 1
10 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 ...
user avatar
  • 811
1 vote
1 answer
477 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 NVIM, ...
user avatar
  • 121
2 votes
2 answers
89 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' | ...
user avatar
  • 177
0 votes
1 answer
108 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 ...
user avatar
-1 votes
1 answer
55 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 ...
user avatar
  • 381
0 votes
1 answer
449 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 ...
user avatar
  • 143
0 votes
1 answer
78 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 ...
user avatar
  • 149
2 votes
1 answer
134 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 ...
user avatar
  • 1,648
0 votes
1 answer
960 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 ...
user avatar
0 votes
1 answer
51 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 &...
user avatar
1 vote
1 answer
214 views

In vim8.2, is there any difference between using :term vs :shell?

In vim 8.2, is there any difference between using :terminal versus :shell to run commands on shell? Or are they identical? I would like to know if there are any specific use-cases for using :shell vs :...
user avatar
0 votes
1 answer
84 views

What is :silent !echo doing? Why does it get the cursor to the top?

This question on StackOverflow triggered my curiosity. What does :silent !echo doing? The first time I saw something like :excommand !shellcommand was when I was looking for a way to save a read-only ...
user avatar
  • 1,648
3 votes
1 answer
47 views

Repeating command for running external script?

I have a script called lorem.sh which takes in the number of paragraphs(first argument) and number of lines in each paragraph(second argument) and prints random text of that format to standard out. I ...
user avatar
1 vote
2 answers
244 views

Pass visually-selected text as argument to script

I am trying to write a command that passes selected text to a shell script. The command works fine when there is no \n character in the selected text (using Visual mode). :vmap <Leader>tts 0y:...
user avatar
5 votes
2 answers
335 views

How to put partial command in command bar?

I am trying to do something like this, from a function: nmap <F5> :!python % Pressing F5 in this case causes the command :!python % to be left in the command line. This is preferred for me, ...
user avatar
1 vote
0 answers
455 views

Vim: How to have YouCompleteMe autocomplete shell script variable names and functions from "source"d files?

I use macvim with YouCompleteMe (YCM), which I recently updated and recompiled. I followed the YCM instructions for OSX. I'm also using iterm2, tmux and zsh, all of which are installed with brew and ...
user avatar
  • 111
1 vote
1 answer
144 views

vim/gvim freezes when shelling out, how to trace events?

NOTE: This underlying problem was solved by an update of Cygwin packages and re-install of vim. However, the question of how to trace errors in shelling out remains, so answers along that front would ...
user avatar
1 vote
2 answers
372 views

Vi: how to use bash from the vi command line?

Suppose I have mapped the following function: noremap <C-F12> :! bash -c "\ git rev-parse --show-toplevel \ | xargs -I {} \ ctags -R --sort=yes --c++-kinds=+p --fields=+iaS --extra=+q {}...
user avatar
  • 123
1 vote
0 answers
12 views

How to access subprocess exit code [duplicate]

I want to write function that passes current line and file to external program and saves its output into register, e.g: function Foo() let l:current_line = line(".") let l:current_file = expand("%...
user avatar
  • 121
0 votes
1 answer
366 views

in macOS, shell escape to bash not zsh

On macOS I've set my login shell to bash instead of zsh, which became the default in Catalina (Terminal > Preferences > General > Shells open with: > /bin/bash). But when I shell escape from vi (from ...
user avatar
1 vote
2 answers
797 views

Parsing output of json file with jq

I have the following windows.json file [{ "id":5178, "pid":40345, "app":"Alacritty", "title":"Alacritty", "frame":{ "w":880.0000, "h":531.0000 } },{ "id":...
user avatar
  • 149
1 vote
1 answer
117 views

Command to open pdf file when editing a latex document

I have this command to open the pdf created by a latex document: autocmd FileType tex nnoremap <leader>p :silent !open $(echo "%:p" \| sed s/.tex/.pdf/g)<CR> which works, but I'd like to ...
user avatar
  • 149
7 votes
1 answer
249 views

Difference between `:!{cmd}` and `:w !{cmd}` regarding alternate screen

On a Linux platform I see this difference of behavior between running a shell command with :!{cmd} (which just runs the command directly) and with :w !{cmd} (which passes the buffer as standard input ...
user avatar
  • 25.8k
6 votes
2 answers
293 views

Shell scripting: A more elegant way to complete then...fi, do...done, case...esac pairs?

The problem In shell scripting, conditionals and loops don't use curly braces to indicate blocks, but rather special keywords: if [ ... ]; then statements close with fi, while [ ... ]; do statements ...
user avatar
  • 165
10 votes
3 answers
4k views

Why does !cd not change the directory

I'm going through vimtutor and just learned about using :!<CMD> to execute a shell command from within vim. I read a bit up on why not to use just :<CMD> and apparently it's because some ...
user avatar