NeoVim terminal support - neovim

This is my config init.vim : https://github.com/NeuralNine/config-files/blob/master/init.vim
when i do :TerminalSplit bash i get the terminal in this process which works fine.
but when i do :TerminalSplit bash on this process terminal just looks empty and not working fine, why is that ?

The problem
You'd need to create an issue on vim-terminal for that but it looks like that this plugin isn't maintained anymore since the last commit is 4 years ago.
Alternative fix
Anyway as an alternativ you can try to use the builtin :terminal command which can open up a terminal for you as well. Here's a little mapping which you can use:
nnoremap <silent> <C-t> :vsplit <bar> :term<CR>
This will create a new window on the right and starts a new shell for you. You can also add the following snippet to your init.vim:
augroup TerminalSplitup
autocmd!
autocmd TermOpen * setlocal list
autocmd TermOpen,TermEnter * startinsert
augroup END
which should bring you automatically into insert mode if you open up that terminal-window.
Also another hint:
tnoremap <silent> <Esc> <C-\><C-n>
use this mapping if you want to be able to scroll through your terminal. This mapping will let you leave the insert mode in your terminal to be able to scroll through the terminal-buffer with the normal vim-keybindings.

Related

Configure binding to perform predefined search in Tmux

I'm trying to find a way to jump to the previous prompt in iTerm using tmux. Can I set a binding to search a unique phrase within my prompt?
So to expand on Yuriy's answer. Inside your terminal you can run the following commands:
tmux copy-mode ; tmux send -X search-backward 'Example'
That should put your current tmux pane into copy-mode and then initiate a search for 'Example'. Now instead of typing that every time we want to search we'll create a shell script(lets say /tmp/search.sh) and then a tmux binding to that script
Contents of /tmp/search.sh
#!/usr/bin/env bash
tmux copy-mode ; tmux send -X search-backward 'These'
make sure you make it executable with chmod +x /tmp/search.sh. At this point you can test that it works by simply calling the script from your tmux session. To add it as a binding you can something akin to the following to your ~/.tmux.conf file:
bind p run-shell "bash /tmp/search.sh"
Make sure you source refresh the configuration in your tmux session and your new binding should initiate the search.
The canonical way of doing this is write a bash script to issue the commands back to your tmux.
But I'd like to suggest a mod that allows way more flexible scripting: http://ershov.github.io/tmux/ (I'm the author)
Using this mod, your problem can be solved this way:
bind p copy-mode ";" tcl {
set s [copy-mode-screenline -ex [copy-mode-get-cx]]
cursor-up
send-keys "?" "\x15$s"
}
This will read the current line from the beginning up to the cursor position and search for the previous occurrence of it.
The key 'p' can be changed to your preference.

Does the mongo shell support vi editing?

I need to carry out some very tedious command line ops on my mongodb. Has anyone tried setting the shell editing to vi?
Would be very useful if I can search my command history and change/replace.
You can set the EDITOR environment variable to point to vi/vim and MongoDB will use it when you issue the edit shell command, or you can use the same EDITOR variable in javascript to override the environment value. Hence you can add the setting to your .mongorc.js file to ensure it is set as you wish each time without manual intervention.
Example from the mongo shell:
> EDITOR='/usr/bin/vim'
/usr/bin/vim
> db
test
> edit db
Which fired up vim for me as follows (abbreviated output for brevity):
1 test
~
~
~
"/tmp/mongo_edit1449005704.js" [noeol] 1L, 4C
In terms of your command history, that is kept in the file ~/.dbshell (as long as you are using something newer than 2.2.0) and can be edited directly.
Something to note: you can use Ctrl-r to reverse search and edit on the command line (hit Ctrl-r again to go one match further back, Ctrl-s to go forward etc.), just like you can in modern BASH shells. For a full list of the keyboard shortcuts, have a look here.

Command to clear the Git Bash screen, including output buffer

Is there any command in Git, that clear the screen. for example in window command line after execute a lot of code, if you type cls, then it will clear all the previous code. so i want the same type of functionality in Git. so can anybody will tell me the command name.
Actually you are looking for a Unix user environment command
clear
or you can use the keyboard shortcut
ctrl+l
http://en.wikipedia.org/wiki/Clear_(Unix)
To clear entire command history in Git Bash.
history -c
try using reset command, it will absolutely clean your screen but you will still have access to previous commands
reset
Neither clear nor history -c does the work actually.
Scroll up, all commands will be visible.
Solution:
If you are in Windows 10, and using mintty 2.7.9 (or above ?) for git bash,
use Alt + F8 ... this will work.
Best of luck.
Happy coding.
Reference: here (Perhaps it didn't work for Windows 7)
Neither clear nor history -c was clearing the history permanently.
All commands will be visible when scrolled up.
So, I solved the issue by:
In my instance the path for bash history was:
/c/Users/<your_username>/.bash_history
I removed the file by the following commands:
rm ~/.bash_history
After that, I restarted the terminal. the commands were gone.
CTRL + L
search for more shortcuts in: here
Another option is modify (or create in your user folder) your .bash_profile and add this:
alias cls='clear';
With this you can clear the bash with a 'Windows' command.
At the moment I use
clear;reset;clear
(in one line) and it sort of works (git version 2.32.0.windows.1).
Most times clr, clear and cls doesn't work use ctrl c to continue writing commands
use clear only without git command
" clear "

Opening editor while the edit mode is vi in Readline

I have set my readline mode to be vi in my ~/.inputrc
set editing-mode vi
I came to know that when you are in command mode, you can press v to open up current line in the editor defined in $EDITOR variable.
This works for me. But when I change the content in my editor, I am not sure how to get those changes back to my command line. How to do that?
After you make your changes just save and quit. The command will be executed after you quit. If you want to look at the command after you have executed it you can just push up.
If EDITER=vim or EDITOR=vi use :wq to save and quit

How do I get the "Command Buffer" in Solaris 10?

When working on a linx CShell u get the option to press the up / down arrows to select the last command/s typed or the Command Buffer. This even works on Windows.
However this is not functional when working on Solaris, to which i recently switched. I am guessing that the shell is also a CShell.
Please tell me what key combination is required to have this feature on Solaris ?
The default shell in Solaris has command history, but you can also use Bash instead, it's more user friendly. Just type 'bash' (no quotes) at the command line. You can also edit /etc/passwd to make bash your default shell.
The "official" default shell for Solaris is actually sh, the original Bourne shell (see Chapter 10 of the Advanced User Guide for Solaris for more info). If you'd like to change it to csh or tcsh—and you're not root (it's generally considered bad practice to use anything but sh as root's default)—just issue passwd -e /path/to/shell_of_your_choice <loginname>. I'm guessing this would probably look like passwd -e /bin/csh <loginname>, but you'd probably want to make sure it exists, first.
It may be that it's the Korn shell in which case try <ESC>k.
bash at least will allow you to switch modes with "set -o vi" or "set -o emacs".
Maybe you can use the !! command, to repeat the previous one.
Use "echo $SHELL" to see what your login shell is. If it's ksh or bash, try "set -o emacs". If that works, you'll be able to use ^P to go back a command. ^R lets you search for a command, ^F and ^B to move around within the command.
If you can´t change your default shell, or you just want to try out one that works, you can kick off any other shell from your command line. I recommend you tcsh, which will have good command line editing and history using the arrow keys. Type /bin/tcsh at your prompt to try it out. You can use the earlier responses to change your default shell if you like tcsh. Make sure your have the following in your $HOME/.cshrc file:
set filec
set history=1000 # or some other large number
set autologout=0 # if you are logging in remotely under your account.
I hope this helps.
You enable history temporarily if you use BASH by typing
HISTSIZE=1000
which will enable up and down keys and store 1000 commands. After termal disconnetion all history will be gone.
This works on solaris 10.
For permanent solution add these lines to ~/.bashrc
HISTSIZE=1000
HISTFILESIZE=1000