how to start the neovim gio from the cli - linux

I'm trying to switch from vim/gvim to neovim on Linux. Up to now my standard workflow started with opening the cli, navigate to my project directory, and run gvim <filename> with the file I intend to start working with.
With neovim I can start it from the KDE menu to get a nice GUI. according to the menu settings, it simply runs nvim with an optional filename parameter. But I don't find the way to run nvim from the cli in a way, that it starts the GUI. Running nvim <filename> simply starts the cli UI.
Google gave me a lot of interesting information, but not, what I'm looking for.

There are different GUIs for neovim. Check which one do you actually use and start it from the command line. Navigate to the KDE menu for neovim GUI, right-click on it and select Edit application... Go to the Application tab and check the Command edit box. There you'll see the actual command which is run by KDE when you select the corresponding menu item. You can create your own shell script or alias which will run this command and use it on the command line.
UPDATE
Maybe some parameter or environment variable is passed to nvim so it changes its behavior. You can try to see what system call KDE actually performs to start the editor. For example, I'm using KDE plasma, so pidof plasmashell gives me the pid which I need. Then:
strace -f -v -e trace=execve -p `pidof plasmashell` &> plasma.trace
After that go to KDE menu and start neovim. Terminate the strace command with Ctrl-C and check the plasma.trace file for the execve system calls made to start the neovim process.

Related

How do I run a shell command from vim in the existing terminal SCM session?

Here's the problem statement:
I open a GNOME terminal and run a startup script setup_myproject_view1 which sets up an SCM session and sets some enviroment variables.
I open terminal vim and start browsing through some files often in multiple split panes (:sp, :vsp)
I realize that I need to edit and save one or more of these files. But before I can do that I need to check out the file from the SCM server/depot.
Now I have multiple options:
Close all my vim panes and run the checkout command in the shell and then open one or all of the files I had open before. Very tedious.
Open a new terminal window or tab and run the startup script and checkout the file. Then return to the original terminal, run :e to load the file again with write permission enabled and proceed to edit it. Still tedious because I have to run the startup script (so I have to remember which project view I'm working in) and switch through windows/tabs.
Run the shell check out command from vim using :shell or :!. This would be ideal because I'm quickly able to return to editing without breaking my train of thought. But the shell inside vim again does not have the startup session setup_myproject1_view1. Nor do I want to put setup_myproject_view1 to run automatically in my shell's .cshrc file because I have different projects and views: setup_myproject3_view2, etc.
So how can I run a shell command conveniently from vim without having to setup the SCM project view?
you can pause vim using ctrl+z, do your checkout and then resume it with fg if you invoked vim from a bash shell. For more information see bash job control
An alternative, you should modify your setup script to export variables to underlying shells. For example if your script is like this:
# script.sh
MEH=4
you will get this result when you use it:
source script.sh
vim
:shell
echo $MEH
exit
but if you change it like this:
# script.sh
export MEH=4
you will get this result when you use it:
source script.sh
vim
:shell
echo $MEH
4
exit

open vim file in new unix terminal

How to open existing vim file from unix shell (bash) in new terminal (not in same/new tab of existing terminal) on local machine ?
Also is there any way to split file on new terminal (not in same/new tab of existing terminal) from inside vim ?
How to open a new terminal is platform dependent; This doesn't really have a whole lot to do with vim itself.
For example, if you're using GNOME you could do this by running gnome-terminal -e "vim $filename" & disown. Look up the documentation for the terminal emulator you're using to find out how to launch a new terminal and execute commands in it.
Another (IMHO much better) solution is to simply use GVim for situations like these, unless you have a very good reason to run vim in the terminal (if you're running this over ssh this won't work anyway, in that case you're better off using a terminal multiplexer like screen or tmux).
PS: bash isn't a terminal (emulator); bash is a shell. If you just run a new instance of bash it'll run in the same terminal, which is not what you want here.
Try this:
vim [your file]
If this isn't working for you, make sure you have it installed with:
sudo apt-get install vim
If you're already IN vim do
:edit [your file]

Can linux or mac terminal commands scroll up instead of down?

I'm wondering if there is a way set a linux or mac terminal so that you are always entering commands at the top of the terminal screen, and previous commands are below it.
Example
-----Screen top----
>EnterCommand
>PreviousCommand 1
>final line of Previous Command 1 output
>second to final line of previous command 1 output
-----Bottom of screen-----
Thanks!
Such a feature is not built into the standard *nix terminal driver; a terminal application would have to be specifically written to translate newlines and line wrapping into upward motion instead of downward. Note that this will likely break a number of TUI applications, so it is not recommended to use them with such a terminal application.
This seems pretty close to what you're asking for:
https://github.com/swirepe/alwaysontop
To use it run:
git clone https://github.com/swirepe/alwaysontop.git
cd alwaysontop/
source alwaysontop.sh
If you decide you like it just source it in your .bashrc or .bash_profile with something like:
echo "source ~/alwaysontop/alwaysontop.sh" >> ~/.bashrc
Hope that helps!

How do I open a new window (shell) from command line in Linux?

I'm working with a tool right now that requires me to putty to a remote host, login, run a series of commands to start an engine, open a new window (and login again) to start a different engine, then open a third window (and again, login) to actually use the tool (leaving the engines running in those first two windows). I'd like to write a shell script to automate the process so that I could just open one window, type "sh whatever.sh" and be off and running, without physically opening the new windows and logging in again. However, I can't find a command to get me from one window to the next. Any thoughts?
You can just background the first processes by adding an ampersand (&) to the command line or pressing Ctrl+Z when it is running (and then enter bg to let the process continue, more information about that with jobs).
If that's not enough, you can create virtual shells with screen or tmux.
If you've redirected X (i.e. you can access GUIs over ssh), you can also just start a new window by executing your favorite (GUI) console program, like xterm, konsole, gnome-terminal, etc.
Are you familiar with jobs on linux?
nohup whatever_1.sh &
nohup whatever_2.sh &
nohup whatever_3.sh &
Or perhaps screen would be of use here:
https://serverfault.com/questions/25301/job-control-and-ssh
See also, nohup:
http://en.wikipedia.org/wiki/Nohup
The bash command opens a Bourne-again shell (bash) session.
Try typing in "konsole". That should open a new bash window and set the focus to it.
On my Ubuntu 18 I just type the command:
gnome-terminal
and a new shell opens... I don't like the above answers because xterm and konsole most likely not already be installed.
Shell script on target machine cannot be aware of putty windows on client machine.
Consider using Screen : http://www.gnu.org/s/screen/ - it is clean and powerful way.
I think you need command line window then write:
$ xterm
# new window started
If you need python in new window:
$xterm python
#now a window will shown with python shell
Another nice option from Xfce's terminal:
xfce4-terminal

Screen and Cygwin: no tab completion?

I'm having some problems working with my development environment. Specifically, after I invoke the screen utility from within Cygwin I lose the ability to do tab completion. Before I invoke screen however tab completion works just fine.
I messed around with setting different values for the TERM env variable (VT100, xterm etc) but without success. It must be something trivial but I have no idea anymore. Does StackOverflow have any suggestions for me?
when you issue 'screen' from inside cygwin it might put you in another shell like /bin/sh instead of /bin/bash (and bash is where you're getting the tab completion from).
To fix the problem you could edit your .screenrc file (found in your home directory) and add in this line:
shell bash
Then try running screen again and you should see tab completion work within this new window.
The problem is that bash needs to be run as a login shell in order to have tab completion in the default cygwin setup. If you run bash in a cygwin bash you won’t have tab completion either. To set screen to run bash in login mode, add this line to your ~/.screenrc file:
shell -bash
I had a similar problem with git autocompletion not working when using screen on a linux machine, but wasn't due to a different shell. I fixed it using this question: Git autocomplete in screen on mac os and doing the following:
Get the git autocompletion script
curl https://raw.github.com/git/git/master/contrib/completion/git-completion.bash -OL
why would you want that hanging around?
mv git-completion.bash .git-completion.bash
add this line to your ./bashrc
source ~/.git-completion.bash
Then in your terminal
source ~/.bashrc
That worked for me.
(I imagine after three years you've probably solved your problem, but I hope this helps someone else)

Resources