tmux-config icon indicating copy to clipboard operation
tmux-config copied to clipboard

yank.sh updated for FreeBSD

Open RafalLukawiecki opened this issue 8 years ago • 3 comments

There is no ss natively on FreeBSD, but there is sockstat. This was making yank.sh fail. I have added another elif clause and a check for ss and sockstat presence, as yank.sh was failing. Also the usual replacement of #!/bin/bash with #!/usr/bin/env bash. Bear in mind that I use OSC52, and not xclip etc, as I do not use X11, only text mode, on remote servers. I have tested that elif clause using a different port to make sure it works, but I have not tested it with xclip. My grep -q test simply checks if there is a listening port, I am not sure if you need to test for anything more—I see you are using a more complex expression than mine with | tail -n +2 | wc -l, but I do not know why, as I cannot see what those two lines would contain.

Feel free to combine lines 26-29—I did not want to change your code too much.

Many thanks for creating your yank.sh script.

PS. I would keep this pending till tmux-online-status PR has merged.

RafalLukawiecki avatar Dec 10 '17 12:12 RafalLukawiecki

@RafalLukawiecki

Given that ss is not present on FreeBSD. Maybe it makes sense to replace ss with regular netstat altogether to avoid 2 conditional clauses.

I guess, something simple like this would work:

elif [ -n "${copy_backend_remote_tunnel_port-}" ] && netstat -tln | grep -q ":$copy_backend_remote_tunnel_port"

Could you please check and tell if netstat -tln is present on FreeBSD?

samoshkin avatar Dec 12 '17 18:12 samoshkin

netstat does not take -t option on FreeBSD, and I am not sure what its function is—had a quick look on https://linux.die.net/man/8/netstat but I do not see that option there, either.

In any case, have a look here to see what we can do with netstat: https://www.freebsd.org/cgi/man.cgi?query=netstat

The output from netstat -ln looks like this, so the separator between the address and the port is just the final dot for IPv4 addresses. Feel free to ping me with sample invocations to try. I will be able to test more in-depth later tomorrow, as on a deadline at the moment, but I can do quick checks, like this one, without a problem.

screen shot 2017-12-12 at 18 15 29

RafalLukawiecki avatar Dec 12 '17 18:12 RafalLukawiecki

Ok, I've prepared new revision using netstat instead of ss.

I haven't merged your pull request, because looks like it includes a bunch of irrelevant commits, so I just pick up your changes as a patch.

The commit is https://github.com/samoshkin/tmux-config/commit/95efd543846a27cd2127496b74fd4f4da94f4a31, it's already in master. So you can just catch up with upstream's master and check it.

For Linux and FreeBSD I use netstat -4 -nl, on OSX netstat -f inet -nl. It's just about showing only INET sockets, and hide UNIX sockets and others.

Those small differences between platforms are very painful indeed - feels like I'm adopting webapp for IE6.

samoshkin avatar Dec 12 '17 19:12 samoshkin