Date: Thu, 11 Apr 2019 11:09:20 +0200 From: Christian Barthel <bch@online.de> To: Polytropon <freebsd@edvax.de> Cc: FreeBSD Questions <freebsd-questions@freebsd.org> Subject: Re: Column widths FROM / WHAT in w(1) Message-ID: <87lg0ghprz.fsf@x230.onfire.org> In-Reply-To: <20190406153319.36f41b8f.freebsd@edvax.de> (Polytropon's message of "Sat, 6 Apr 2019 15:33:19 %2B0200") References: <20190406153319.36f41b8f.freebsd@edvax.de>
next in thread | previous in thread | raw e-mail | index | archive | help
--=-=-= Content-Type: text/plain Polytropon <freebsd@edvax.de> writes: > Any idea on how to get the old layout of w back, instead > of increasing the terminal width? w(1) is using ioctl's to determine the column width of the terminal. Other tools like ps (-w) and top can be configured to change the column width. On Linux, it seems that the variable COLUMN allows overriding it. Attached is a small patch that would add an environment check on the COLUMN variable. Further processing would be possible then, like: # COLUMN=180 ./w |sed 1d| cut -c 76- WHAT tmux: client (/tmp//tmux-1000/default) (tmux) cut -c 76- -tcsh (tcsh) I am not sure if there is another way to change the perceived column width in w(1). -- Christian Barthel <bch@online.de> --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=column_in_w.patch diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c index f2da6485a74..2db79121e4a 100644 --- a/usr.bin/w/w.c +++ b/usr.bin/w/w.c @@ -137,11 +137,12 @@ main(int argc, char *argv[]) struct kinfo_proc *dkp; struct stat *stp; time_t touched; - int ch, i, nentries, nusers, wcmd, longidle, longattime; + int tenv, ch, i, nentries, nusers, wcmd, longidle, longattime; const char *memf, *nlistf, *p, *save_p; char *x_suffix; char buf[MAXHOSTNAMELEN], errbuf[_POSIX2_LINE_MAX]; char fn[MAXHOSTNAMELEN]; + char *colenv; char *dot; (void)setlocale(LC_ALL, ""); @@ -315,6 +316,10 @@ main(int argc, char *argv[]) ttywidth = 79; else ttywidth = ws.ws_col - 1; + if ((colenv = getenv("COLUMN")) != NULL) + if ((tenv = atoi(colenv)) > 0) + ttywidth = tenv; + argwidth = ttywidth - WUSED; if (argwidth < 4) argwidth = 8; --=-=-=--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?87lg0ghprz.fsf>