1

I have an alias for neovim-qt thus defined:

gvim='nvim-qt --geometry 500x320 --'

This allows me to call gvim foo.py ook.py and have a QT window running neovim with two tabs, one for each file.

However, this does return me to the prompt of the shell. I have to add a & at the end of the command line. Since I am lazy and forgetful, I keep not doing ctrl+z and bg which is irritating. I want to add a & after all other arguments in the alias.

How do I do that?

6

To do anything more complex than to replace a simple command with an alias, use a shell function.

In your case:

function gvim {
    nvim-qt --geometry 500x320 -- "$@" &
}

Aliases are not really suited for much more than simple things, like adding your favourite flags to ls or whatever.

  • Just out of curiosity - what if I also want to "detach" the process from the terminal that spawned it? So that I can close the terminal and keep on editing the file in nvim-qt. Using "$@" & disown does not seem to work (I remember doing that for gvim a long time ago). Is there any other way? – Stunts Nov 9 '16 at 21:47
  • 1
    @Stunts Unfortunately I don't have access to this version of Vim (I actually do not run X11 on my machines at all) so I don't quite know how it behaves. GVim shouldn't need & nor disown as it detaches by default, if I remember correctly. – Kusalananda Nov 10 '16 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.