Closed JakubKahovec closed 6 years ago
I like the idea. How do you imagine it would work? What would it look like?
Thanks ;-) It might be something like you run fkill-cli and next to the Running processes there'd be in brackets by what you're searching and you can switch it by a shortcut.
Search running processes (by Name/Pid/Port) :
I see two options
fkill -p
or fkill --port
could start the tool in port
mode where searching will match the port.
Just run fkill
and if the input looks like a port (numeric, between 0 and 65535, ...) use the port is filter strategy.
I think automatic parsing would be nicer, but one downside (?) is that you would miss the ability browse through ports. Not sure that's something people would need though.
What do you mean with browse through ports?
@SamVerschueren I mean, if you just want to see what apps are using which ports.
You could use automatic parsing for finding and killing (when you know the port number connected to the proc you want to kill) and then also have a 'ports' subcommand, maybe?
fkill 8080
# searches for procs using port 8080, the same what automatic searching currently works (maybe, if there's a proc owning the port it jumps to the top of the search, and proc names / args containing the port by coincidence come below it)
fkill ports
# displays scrollable list of procs using ports, with the ports in their own column along side pids
Sidenote; https://www.npmjs.com/package/node-netstat may be good for this.
Careful, people will assume the first arg to fkill
is a PID or process name, not a port, and they can conflict. Probably better to have fkill --port 8080
or fkill ports
then search with port:8080
or something like that.
You can find all port-> process mappings with netstat -tan
or lsof +c 0 -i:8080
.
@sindresorhus, @pirate how do you feel about:
fkill ports # interactive autocomplete search based on port number
fkill ports 8080 # kill the process currently using port 8080
fkill ports 8080 8081 8082 # kill the processes currently using ports 8080-2
using a ports
subcommand will limit any confusion between port number and pid.
I'd rather a flag than a subcommand, as the word ports
itself could be a process name, and that leads to ambiguity with parsing the first argument. How about --port
?
yep, that makes sense - --port
works for me.
fkill --port # interactive autocomplete search based on port number
fkill 8080 --port # kill the process currently using port 8080
fkill -p 8080 8081 8082 # kill the processes currently using ports 8080-2
👍 for your second example, I think only allowing fkill --port 8080
makes more sense, (otherwise you run into the pid vs port ambiguity problem).
do you mean fkill --port 8080
vs fkill 8080 --port
? Because i think flags should be treated as non-positional; so if -p or --port is present then positional arg 1-n will always be treated as ports, not pids.
Up to you, I personally favor stricter argument parsing, but it's your call @sindresorhus & @coffeedoughnuts ;)
do you mean fkill --port 8080 vs fkill 8080 --port ?
The argument parser we use supports both, but we should only document fkill 8080 --port
as it's the clearest. In fkill --port 8080
it could both mean it's the value of --port
or the first argument.
I'm ok with a --port
flag.
how about searching by port after user typed colon :
?
$ fkill
user types:
:8080
shows list of apps on 8080
I like it.
On Tue, Apr 4, 2017 at 2:35 PM Yury notifications@github.com wrote:
how about searching by port after user typed colon : ? $ fkill user types: :8080 shows list of apps on 8080
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sindresorhus/fkill-cli/issues/19#issuecomment-291592332, or mute the thread https://github.com/notifications/unsubscribe-auth/AAfOCwhpjLZx6_QDQKhJqNEp5IdJUHF0ks5rso1WgaJpZM4MThKz .
-- --From Nick (Mobile)
Yeah, I would be fine with that too.
I assume it would be:
$ fkill :8080
And
$ fkill
? Running processes: :8080
Is everyone good with this?
// @SamVerschueren @coffeedoughnuts @MarkTiedemann @AlexTes
LGTM.
Yep, :PORT seems good to me;
Cool. Let's go with that then. Pull request welcome :)
Marking as "help wanted" again. See https://github.com/sindresorhus/fkill-cli/pull/27 for previous attempt.
It'd be great if it's possible to also search by a port being open by a process