Questions tagged [bash]
BASH is the GNU Bourne Again SHell, the successor to the classic Unix Bourne sh (shell). It's the default shell for various Linux/GNU systems.
100
questions
0
votes
2
answers
161
views
Writing a bash script to startup Vim in a particular configuration for a project
I want to write a bash script that starts up a Vim session using a specific configuration.
For instance consider a C project with the following structure
project_dir
- src
- file1.c
- file2.c
...
0
votes
1
answer
40
views
Adding colour to the output of a bash command?
I'm working with pytest and have keybindings set up to run all the tests in the specific file I'm working on. The command I run is:
:! pytest -vs "<C-r>%"
However, the output of this ...
2
votes
1
answer
42
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 ...
9
votes
2
answers
1k
views
Syntax highlighting for shell scripts broken
Since recently my syntax highlighting for ft=sh (also syn=sh is set) is broken:
Why is that? How can I fix it?
Edit:
I'm using Vim 9.0 with patches 1-1302.
I add here the code from the screenshot. ...
0
votes
2
answers
171
views
What does ! in the %retab! mean?
%retab! can replace all characters with spaces.
The % in command %retab! means the whole lines in the current file.
help retab show something such as:
With !, Vim also replaces strings of only normal ...
0
votes
1
answer
76
views
Which linux commands are native to Vim?
You can execute commands from vim like this:
:!cp <src> <dest>
However, the command is executed externally. The above can save typing and effort, but which are the commands that don't ...
6
votes
0
answers
170
views
How to fix bash highlighting for left shift?
I have a bash function that does some bit-bashing (no pun intended, and I know the shell is not the best language for that sort of thing), but the syntax highlighter in vim is convinced that this:
(( ...
1
vote
1
answer
336
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 ...
1
vote
1
answer
35
views
Turning on vi in terminal after returning to terminal [closed]
So I have set -o vi set in my .bashrc file
When I open terminal it starts in INSERT mode.
How can I make it so that it starts in NORMAL mode?
0
votes
0
answers
256
views
Call custom bash function from Vim
I have created a bash function, in its own .sh file, which I want to use from within Vim, and later use if from within the lightline config file. I have tried many ways, but I cannot make it work.
...
0
votes
1
answer
36
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 ...
0
votes
1
answer
740
views
How to run a bash one liner within nvim
I am running the latest version of nvim on the latest version of arch.
I have this bash one liner which works as intended
echo; lpstat -p | sed 's/printer //g' | sed 's/is idle. enabled since.*//g'; ...
0
votes
0
answers
198
views
How do I open up a new interactive shell from the command line?
When I run this command from the command line:
taskopen -A c6cb317e
It opens an interactive menu for choosing a file. After making a selection, it then opens a file in vim for editing, or, if the ...
0
votes
1
answer
246
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 ...
1
vote
1
answer
288
views
How can I open the last opened file by vim and go to a specific line?
I want a bash function to open the last file opened by vim and goes to a specfic line
I tried
vil()
{
vim -c "normal! '\''0 :$1"
}
0
votes
1
answer
110
views
How do I get the line numbers to permanently appear in vim [duplicate]
I keep wanting to customize vim, how do I get the line numbers to show up everytime i open up VIM.
-1
votes
1
answer
103
views
vimrc, like exec but replaces current process (fork?)
Such as in the following code:
let cpath = getcwd()
let cfile = expand('%')
function Run_file_hopper(cpath, cfile)
silent exec "! . ~/path/somescript.sh" a:cpath a:cfile ...
0
votes
0
answers
36
views
Attaching audio spoken word "escape" to Esc key stops escape key escaping to normal mode in nvim. How to fix?
I am running the latest versions of: Arch, nvim, and the Openbox window manager.
I often don't know whether I have actually hit the escape key or not, when exiting another mode to normal mode. If I ...
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 ...
1
vote
0
answers
564
views
Retrieving declaration not supported for filetype
I am currently using vim-lsp for bash.
As in https://github.com/bash-lsp/bash-language-server#vim I have added in my ~/.vimrc the followings :
if executable('bash-language-server')
au User lsp_setup ...
5
votes
0
answers
190
views
Can I get vim to indent correctly after a here document?
In an account with just an emtpy .vimrc, under Xubuntu 20.04 and vim 8.1, I get strange indentaion after my here document if I reindent with gg=G
I've boiled down an example from some pretty tangled ...
2
votes
1
answer
229
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 ...
1
vote
1
answer
2k
views
Cannot Edit ~/.vimrc file without both E297 error and E667 From Appearing
I am SSHing into an Ubuntu machine where I use Bash as the shell. I used to be able to edit my ~/.vimrc file very easily. Now, whenever I try to write to it, I get a warning
E297 write error in swap ...
1
vote
1
answer
234
views
How to escape a single quote when passing an ex-mode command from the command line, back to the command line?
Here is the command I'm trying to escape a ' from bash, to vis' to ex-mode, and then back to bash so it can be read into the buffer again:
vi -c 'sp | enew | read ! echo "Use to jump between ...
1
vote
0
answers
128
views
How to set the Bash python env and vim python env paths the same?
When I check for python version in vim file, it displays 3.6 whereas it shows python 3.7 when I check from the bash terminal. As a result, when I pip install from the terminal, it installs in the ...
2
votes
1
answer
374
views
Open or create a specific Vimwiki page from a command prompt
For opening the index page of my Vimwiki instance, I have the following alias in my ~/.bashrc:
alias vimwiki='vim -c VimwikiIndex'
But how to open a specific Vimwiki page right from a command prompt?
1
vote
0
answers
238
views
gvim remove menu and toolbar, but keep original geometry
I start gvim with this entry in .bashrc
alias G='gvim -fg white -bg black -geom 80x45 '
and have in .vimrc
set guioptions=aeik
which works as expected and gives me a gvim that looks like vim in a tty, ...
3
votes
2
answers
2k
views
Shell syntax highlighting
I've noticed in bash/shell it highlights $(...) in red, for example:
However, if I change the syntax from ft=sh to ft=bash, it does not do this:
What's the reason for this? Am I doing something ...
4
votes
1
answer
2k
views
Can't search for strings within hidden files with fzf's Rg command in vim
I just installed fzf for my bash terminal and the fzf.vim plugin for vim. I've placed the following code at the bottom of my .bashrc script:
export FZF_DEFAULT_COMMAND='rg --files --hidden --no-ignore-...
0
votes
0
answers
23
views
How to follow while searching regex in vim? [duplicate]
In my previous vim, when i typed /something and after reaching upto so vim started immediately following and with each letter typed i got into new word until i got the perfect. However this following ...
1
vote
2
answers
535
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 {}...
5
votes
2
answers
723
views
Open multiple files in custom split layout
I want to open three files file1.txt file2.txt file3.txt in vertical and horizontal split combination, like this:
+-------------------------------+
| | |
| file1.txt | ...
0
votes
0
answers
27
views
How to use bash aliases in ftplugin files? [duplicate]
I want to be able to compile and run C++ files directly from inside vim. I have a custom compilation alias gmm defined in ~/.bash_aliases. I do not want to copy it over to my ~/.vim/ftplugin/cpp.vim ...
2
votes
0
answers
15
views
vim command mode g++ doesn't pick the bash alias [duplicate]
I have g++ alias defined in my .bashrc file as
alias g++='g++ -Wall -DLOCAL=1'
I am invoking following command from vim command/normal mode to compile a program -
!g++ %
The issue is, this ...
6
votes
2
answers
334
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
1
answer
517
views
Whats the benefit of using :term inside Vim compared to a separate terminal emulator app?
I am using iTerm2, which is working well for me. I've been using VIM for almost 2 years now, with MacVim. Then suddenly I became curious whether my coding experience will improve when I use terminal ...
8
votes
1
answer
4k
views
How can neovim on Windows be configured to use gitbash as the shell without breaking temp files?
At work I use neovim on Windows, and set the shell to bash using the bash executable that comes with Git for Windows (gitbash), which is in my PATH. The settings in the minimal init.vim pasted below ...
2
votes
0
answers
482
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
3
answers
12k
views
How to restart vim from within vim?
Here's how I restart vim:
$ vim
:q
$ vim
Is there a way to restart vim so that there is no need to type the second vim in the shell?
3
votes
1
answer
166
views
Cannot sort my bash functions correctly
I'm trying to sort my bash functions inside my .bash_functions file.
Here is what I type :
:g/^function /,/^}$/ s/\n/@@@
:sort /^function /
:%s/@@@/\r/g
EDIT0 : Here is some of the input :
...
2
votes
0
answers
51
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
1
answer
2k
views
Changing PYTHONPATH from inside VIM
Today I was writing code in VIM and wanted to change the PYTHONPATH and so I ran:
:!echo $PYTHONPATH;export PYTHONPATH="/home/oli/git/published_libraries/computer_communication_framework";echo $...
1
vote
1
answer
394
views
Using a login shell only for the :term command
I'm on MacOS, so basically all terminals are login terminals for me which source my bash_profile and load everything I need.
However, the :term command does not source my bash_profile, I believe ...
2
votes
0
answers
99
views
Go to current cursor position when invoking command-line edit mode
If I press v while using either the vi-mode zsh plugin or set -o vi in bash, it opens the line I'm working on in a full vim session. However, this puts my cursor at the beginning at the beginning of ...
3
votes
1
answer
75
views
Invalid syntax for a bash file called catalog
I have a file written in bash (with the she-bang) and called "catalog", and the syntax highlighting is incorrect. If I rename the file, the colors become correct.
I have not configured anything in ...
2
votes
2
answers
718
views
Run processes in shell while editing in Vim
I am a new Vim user. I can do : :! <some command> in Vim to run a bash command in Linux. After that bash command is executed, I can press Enter to go back to Vim. What happens if the bash ...
0
votes
2
answers
2k
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
1
answer
1k
views
Change Vim command :terminal so instead of CMD there will open Bash terminal [duplicate]
I am used working on Vim on Linux, where I use tmux + vim to switch between terminal and vim edit quickly. Now I am trying to setup the same on windows 10.
I try to use gVim on Windows 10, but I like ...
1
vote
1
answer
4k
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?
1
vote
1
answer
93
views
Why do I get "incompatible error" while opening .sh files using vi in cygwin?
I am very much annoyed by this error:
$ vi abc.sh
Error detected while processing /home/DELL/.virc:
line 1:
E518: Unknown option: incompatible
Press ENTER or type command to continue
/bin/bash: ...