Questions tagged [shell]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
31 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 ...
0
votes
1answer
58 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 ...
1
vote
1answer
19 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/ >&...
0
votes
0answers
33 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 ...
0
votes
1answer
39 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 ...
0
votes
2answers
43 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 ...
0
votes
0answers
14 views

Default javac Compiler Plugin Does not Display Shell Output

I want to compile and run a generated java executable inside of Vim quickfix. My .vimrc: function! Make(script) if &ft ==# "c" || &ft ==# "cpp" compiler gcc elseif &...
8
votes
3answers
998 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 ...
1
vote
3answers
49 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 -...
2
votes
2answers
65 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 ...
0
votes
0answers
200 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 ...
10
votes
1answer
1k 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 ...
0
votes
1answer
89 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, ...
2
votes
2answers
55 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' | ...
0
votes
1answer
51 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 ...
-1
votes
1answer
39 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 ...
0
votes
1answer
155 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 ...
0
votes
1answer
56 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 ...
2
votes
1answer
55 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 ...
0
votes
1answer
339 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 ...
0
votes
1answer
36 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 &...
1
vote
1answer
113 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 :...
0
votes
1answer
51 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 ...
3
votes
1answer
34 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 ...
0
votes
2answers
73 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:...
5
votes
2answers
301 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, ...
1
vote
0answers
271 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 ...
1
vote
1answer
98 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 ...
1
vote
2answers
243 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 {}...
1
vote
0answers
9 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("%...
0
votes
1answer
187 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 ...
1
vote
2answers
599 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":...
1
vote
1answer
82 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 ...
7
votes
1answer
194 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 ...
6
votes
2answers
277 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 ...
10
votes
3answers
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 ...
2
votes
1answer
448 views

How to chain shell command with vim Ex command?

I'm trying to do the following: autocmd BufWritePost *.py :!isort % | :edit The isort command in this case is writing to the buffer and so I'd like to reload the buffer to see the changes to the ...
0
votes
1answer
72 views

Is there a way to change the message "press ENTER or type command to continue" to something else?

I would like to change it to make something like a separator between !python % Change this(my computer is in spanish): To something like: Hello World --------------- Hello World --------------- ...
1
vote
3answers
210 views

How can I create a command to remove non-consecutive duplicate lines?

I'm trying to remove (non-consecutive) duplicate lines in a file I have loaded in vim (without sorting them). In several places on the web I've found the nugget awk '!x[$0]++' as a pipe command that ...
1
vote
1answer
163 views

How to indent text between specific line numbers in vim?

Let's say I want to indent everything between lines 40 and 60 (both lines included). One way of doing this is to go to line 40 and indent 21 lines: :40 21>> I am slightly bothered by having to ...
1
vote
1answer
42 views

Why does :! open -a terminal or :! start cmd create totally new "applications"?

Edit: on Windows, looks like it's opening in sysWOW64 instead of system32. Any ideas why? Title. Basically, both of these commands are supposed to open a new console, the former on my mac and the ...
3
votes
1answer
219 views

Unable to set WSL as the shell on gVim

I followed the instructions given in this answer: https://vi.stackexchange.com/a/16436/25843, and I've set my shell to point to wsl.exe like this (wsl.exe path seems to be different on my machine ...
2
votes
0answers
339 views

Use external commands within venv virtual environment

Same question as Use Vim with virtualenv, except for these differences: I'm using bash, not zsh using venv, not virtualenv or virtualenvwrapper I have a keybinding to run the current buffer as a ...
1
vote
1answer
37 views

Cross-platform way to execute command with clean environment?

A plugin I use executes: silent execute '%!cmd' which fails because of a particular environment variable I have set that deliberately modifies the behaviour of cmd. I can fix it with: silent ...
3
votes
1answer
41 views

Add comment to file while opening (C)

I have output from static analyzer, that I parsed with Bash. Now I want Vim to run on specified by analyzer line and add comment containing warning id and description. I tried this, vim $file +$...
1
vote
2answers
90 views

How can I stop Vim from inserting keypresses into the document unless the document is visible?

I have a macro that's essentially equivalent to the following: in insert mode, I press the following keys: Ctrl+O, :, !, t, r, u, e, Enter. This runs the command true in a shell and shows "Press ENTER ...
2
votes
0answers
39 views

head isn't included in syntax/sh.vim

head is a common Unix/Linux executable, but it's not listed in the shell syntax highlighting configuration. In contrast, many common executables are. Specifically, its counterpart, tail, is listed. ...
0
votes
1answer
53 views

How show underlying container for vim, ie xterm etc

When I run :maps that use ! to execute linux commands, the vim display is suspended to show the command output in the underlying container (xterm in my case). When the mapping terminates, any shell ...
1
vote
1answer
109 views

Is it possible to read a shell command's output from nvi's command line?

I was trying see if I can integrate fzf with nvi, but couldn't find a way to do something like :Edit <shell command's output> which would solve my problem. I tried :source nvi.ex -- it works ...
2
votes
1answer
179 views

Why does vim call powershell surrounded by two single quotes?

I'm attempting to use powershell from gvim, and when I do...I set: :set shellcmdflag=-NoProfile\ -NoLogo\ -ExecutionPolicy\ RemoteSigned\ -windowStyle\ Normal\ -Command :set shell='C:\\windows\\...