Questions tagged [shell]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
2answers
49 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
8 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
16 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
196 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
27 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
128 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
257 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 ...
0
votes
0answers
10 views

Run vim in background [duplicate]

Is there a way to send a current "live" vim instance to the background, as if I had run this shell command to start it? vim & I would also like to be able to bring it back using fg or something ...
7
votes
3answers
3k 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
146 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
62 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
145 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
87 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
38 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 ...
2
votes
1answer
84 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
185 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
30 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
40 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
64 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
38 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
42 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 ...
0
votes
1answer
73 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
106 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\\...
0
votes
1answer
44 views

restrict shell command to only part of a line

In a file I'd like to replace some occurrences of triplets of 0 with F, 1 with E, ..., F with 0. Only some, so I can't just pipe the whole file through a bash tr filter; I need a text editor to ...
4
votes
3answers
380 views

Write buffer to command and append stdout back to same buffer

I've opened an empty buffer with just vim. I have a shell script in the same directory that I can pipe SQL to. That script will print the result of the execution to stdout. In my empty buffer, I ...
4
votes
1answer
627 views

get exit status from system() call

Calling the function system("<command>") or systemlist("<command>") retrieves the stdout output from a shell call to <command>. How can I retrieve the exit status of that command? ...
0
votes
1answer
141 views

what does “\033]110\007\033]111\007” mean

I found this snippet online which is apparently a way to make vim a little faster if your terminal background is the same as what vim's is meant to be (right?) " General colors if has('gui_running') |...
1
vote
2answers
724 views

How can I emulate :shell command in Neovim?

There is no :shell command in neovim. :terminal opens a shell without previous output, while :shell contains all the output of the parent shell and all previous shells. Is there any way to emulate :...
1
vote
1answer
33 views

Why does current/shell directory change depending whether drive-letter is used in filename?

Using VIM (v6.3) from a command-prompt (i.e. not gVIM) I'm getting different behaviour for the :shell command depending on whether I specify a drive-letter when editing a file or not. Without Driver ...
0
votes
1answer
92 views

Could backtick-expansion be consistently used for autocompleting filenames within directory tree?

So, I had this keymapping for helping me to edit files: nnoremap <Leader>e :e **/ But this doesn't work with hidden directories. So, I naively added: nnoremap <Leader>d :e .**/ But ...
0
votes
2answers
170 views

Why is `vim -E` always exiting with non-zero exit code when using here-doc?

see the following session in dash: $ printf "foo\nbar\n" > testfile $ cat testfile foo bar $ vim -E testfile <<-EOS > 1 > s/foo/baz/ > x > EOS $ echo $? 1 $ cat testfile baz bar $...
0
votes
1answer
417 views

Weird characters when running :shell

When I run the :sh command I see the following characters If it is relevant, my default shell is zsh and it runs oh-my-zsh also Thanks
0
votes
2answers
524 views

Shell running inside vim windows

Is there a way that a open up a window or buffer, where i can run my bash commands? I thought on something like you know it from VS Code(1). The code windows on the top and a small command prompt on ...
1
vote
1answer
27 views

Retrieving results from variations of system('top') returns errors

Directly on the Ubuntu terminal, I can extract the results from top regarding a specific PID with: top -p <pid> -n1 | awk '/<pid>/' Where <pid> should be substituted with a PID ...
0
votes
1answer
113 views

Identifying the PID of Vim 8.1 internal terminal launched with :terminal ++close

When launching an internal Vim 8.1 terminal for an exclusive program like in terminal ++close ipython, is there a way to identify from vimscript which is the PID of the launched process (i.e. of the ...
0
votes
0answers
51 views

terminal shell behaves differently from normal shell

I run this command in a common terminal: $ ps aux | grep work | grep python | awk '{print $2}' Then I have three different pids, however, in the vim-term window, the same line gave me two pids. ...
3
votes
1answer
546 views

No color in Vim while using Google Cloud Shell

I am using the Google Cloud Shell and wanted to install a theme for Vim. Adding the following to my .vimrc (using vim-plug as a plugin manager): Plug 'mhartington/oceanic-next' syntax enable if (...
1
vote
1answer
2k views

Execute Vim commands from shell

How to execute Vim commands from shell? For ex I want to see man pages of grep command in vim typing command from shell(bash,zsh) command something like: vim ':Man grep' Is it possible?
0
votes
0answers
36 views

aliased commands don't work with the shell ex command? [duplicate]

I have a number of aliased commands in my .bashrc and they work fine on the command line. However, if I use them in Vim, they do not work. For example: :!mycommand results in: /binbash: mycommand: ...
17
votes
3answers
12k views

Can I issue an interactive shell in Vim window?

I know I can :! or :r! to execute external command and optionally insert its output into text. I can even perform :!sh and I'll spawn a shell that will live until I exit it - but while the shell is ...