caseykneale / VIMKiller

Exiting VIM is hard; sometimes we need to take drastic measures
MIT License
1.22k stars 16 forks source link

Advanced vi/m killing #5

Open twe-syde opened 4 years ago

twe-syde commented 4 years ago

I hope you find it useful to solve this issue.

Not tested for arduino libserial but linux standard console only.

caseykneale commented 4 years ago

Fantastic contribution! Unfortunately it doesn't run in the REPL :/.

julia> run(pipeline(`kill`, `$(ps h -C vi -o pid)`, `2>/dev/null`))
ERROR: LoadError: Base.Meta.ParseError("missing comma or ) in argument list")
Stacktrace:
 [1] #parse#1(::Bool, ::Bool, ::Bool, ::typeof(Base.Meta.parse), ::SubString{String}, ::Int64) at ./meta.jl:184
 [2] (::Base.Meta.var"#kw##parse")(::NamedTuple{(:greedy,),Tuple{Bool}}, ::typeof(Base.Meta.parse), ::SubString{String}, ::Int64) at ./none:0
 [3] #shell_parse#350(::String, ::typeof(Base.shell_parse), ::String, ::Bool) at ./shell.jl:79
 [4] #shell_parse at ./none:0 [inlined] (repeats 2 times)
 [5] @cmd(::LineNumberNode, ::Module, ::Any) at ./cmd.jl:387
in expression starting at REPL[39]:1

I'm not 100% sure what is causing this, but,

run(`kill vi`)

Works for one process... Hmmm... Something to do with Julias Bash interop.

I'm using Julia 1.3.2

twe-syde commented 4 years ago

The documentation says "IO redirection can be accomplished by passing keyword arguments stdin, stdout, and stderr to the pipeline function:"

https://docs.julialang.org/en/v1/manual/running-external-programs/index.html#Pipelines-1

Let's give it a try ;)

giordano commented 4 years ago

Why not killall?

Chronophylos commented 4 years ago

killall -9 -r '^n?vim?$' should remove all instances of Neovim, Vim and Vi, as well as nvi.