terminfo descriptions (was: from screen to tmux)

2020-09-09 Thread Vincent Lefevre
Sorry, that's a bit old, but could solve your problem...

On 2020-06-24 11:13:06 +0700, Victor Sudakov wrote:
[...]
> I have a reason but not Debian-related. Since some version, screen has
> started enforcing the "screen.xterm-256color" (sic!) terminal type which
> is missing from FreeBSD's terminal definitions:
> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=246029

This is not an issue. You can get the textual information under Debian
with "infocmp" (with no arguments, it will give you the one of the
current $TERM), send it to the remote machine, then compile it on
the remote machine with "tic" on this file. No need to be root, as
by default, it will install it in your home directory. This is what
I've done for years with various terminfo descriptions (so that I get
the same behavior on various machines I use), and I've never had any
issue with that.

Note: if you don't like something in a terminfo description, you can
change it before running "tic".

-- 
Vincent Lefèvre  - Web: 
100% accessible validated (X)HTML - Blog: 
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)



Re: from screen to tmux

2020-06-24 Thread Victor Sudakov
davidson wrote:
> > 
> > In my Gnu screen setup, the corresponding key sequence (unchanged from
> > package defaults in this respect, afaict) is
> > 
> >   Ctrl-a a
> > 
> > And so to emulate that I would probably replace this line
> > 
> >   bind-key C-a send-prefix
> > 
> > with this one instead
> > 
> >   bind-key a send-prefix
> > 
> > so that old muscle-memory would remain useful.
> 
> Yes, this is much better, thank you.

And now that C-a has become vacant in tmux, we can 
"bind-key C-a last-window"
(yet another case of muscle-memory).

-- 
Victor Sudakov,  VAS4-RIPE, VAS47-RIPN
2:5005/49@fidonet http://vas.tomsk.ru/


signature.asc
Description: PGP signature


Re: from screen to tmux

2020-06-23 Thread Victor Sudakov
davidson wrote:
> On Tue, 23 Jun 2020 Victor Sudakov wrote:
> > davidson wrote:
> > > [Victor Sudakov OP wrote:]
> > > > I'm trying to switch from screen to tmux
> [snip]
> 
> I've thought about the same thing, but inertia is seductive, and I
> have remained --so far-- unaware of specific reasons to bother
> changing.

I have a reason but not Debian-related. Since some version, screen has
started enforcing the "screen.xterm-256color" (sic!) terminal type which
is missing from FreeBSD's terminal definitions:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=246029

[dd]

> 
> In my Gnu screen setup, the corresponding key sequence (unchanged from
> package defaults in this respect, afaict) is
> 
>   Ctrl-a a
> 
> And so to emulate that I would probably replace this line
> 
>   bind-key C-a send-prefix
> 
> with this one instead
> 
>   bind-key a send-prefix
> 
> so that old muscle-memory would remain useful.

Yes, this is much better, thank you.

> 
> > > I started my first session with this command:
> > > 
> > >   $ tmux attach
> > 
> > It is quite counter-intuitive to start a *first* session with "tmux
> > attach",
> 
> I agree, but I'm not sure how much my intuition, or my expectations of
> what constitutes "normal behavior" for a terminal multiplexer, has
> been shaped/warped by habituation to Gnu screen idioms.
> 
> It looks like tmux works a little differently. In particular, it uses
> its config files a little differently than Gnu screen uses ~/.screenrc

[dd]

Thank you for the detailed write up, very informative.

Also, if you have the "termcapinfo xterm* ti@:te@" command in screenrc,
you might find the following command for tmux.conf useful: 

set-option -ga terminal-overrides ',xterm*:smcup@:rmcup@

It prevents tmux from requesting the alternate screen from its parent
terminal, which is possibly what the Xfce or Gnome terminal is using to
decide if it should send the fake Cursor Up/Down keys when scrolling the
mouse wheel.

Without these commands, after starting screen or tmux, the mouse wheel
in Xfce Terminal starts scrolling through command history instead of the
terminal buffer, which can be quite annoying and even dangerous.

-- 
Victor Sudakov,  VAS4-RIPE, VAS47-RIPN
2:5005/49@fidonet http://vas.tomsk.ru/


signature.asc
Description: PGP signature


Re: from screen to tmux

2020-06-23 Thread davidson

On Tue, 23 Jun 2020 Victor Sudakov wrote:

davidson wrote:

[Victor Sudakov OP wrote:]

I'm trying to switch from screen to tmux

[snip]

I've thought about the same thing, but inertia is seductive, and I
have remained --so far-- unaware of specific reasons to bother
changing.


The first line below changes the command key from Ctrl-b to Ctrl-a,
to emulate Gnu screen.

  $ cat ~/.tmux.conf
  set-option -g prefix C-a


This is a nice feature, but not quite sufficient. You won't be able to
send a literal C-a to the terminal if you have just this one line.


Oof. Yeah, that's no good at all.


I have 3 lines doing the same job:

set-option -g prefix C-a
unbind-key C-b
bind-key C-a send-prefix


Thank you. That is much better.

I notice that this will make

  Ctrl-a Ctrl-a

the key sequence for passing Ctrl-a to the application running in a
window pane.

In my Gnu screen setup, the corresponding key sequence (unchanged from
package defaults in this respect, afaict) is

  Ctrl-a a

And so to emulate that I would probably replace this line

  bind-key C-a send-prefix

with this one instead

  bind-key a send-prefix

so that old muscle-memory would remain useful.


I started my first session with this command:

  $ tmux attach


It is quite counter-intuitive to start a *first* session with "tmux
attach",


I agree, but I'm not sure how much my intuition, or my expectations of
what constitutes "normal behavior" for a terminal multiplexer, has
been shaped/warped by habituation to Gnu screen idioms.

It looks like tmux works a little differently. In particular, it uses
its config files a little differently than Gnu screen uses ~/.screenrc

Try the following, with the ~/.tmux.conf that specifies
MyFirstTmuxSession:

 $ tmux kill-server # make sure your user has no tmux sessions

 $ tmux list-sessions # verify that this is so
 no server running on /tmp/tmux-1000/default

 $ tmux start-server # start the server that manages your sessions

 $ tmux list-sessions # see what sessions you have now
 MyFirstTmuxSession: 4 windows (created Tue Jun 23 17:18:33 2020) [80x24]

And now, of course, if you cared to, you could attach that session to
some terminal.

This made more sense to me when I read more carefully in tmux(1)
(somewhat weirdly, under section DESCRIPTION instead of OPTIONS) about
the '-f' command line option that lets you explicitly specify a
configuration file.

Surprisingly, it's full of information about how (and when) the
configuration file actually gets used:

  -f file

 Specify an alternative configuration file.  By default, tmux
 loads the system configuration file from /etc/tmux.conf, if
 present, then looks for a user configuration file at
 ~/.tmux.conf.

 The configuration file is a set of tmux commands which are
 executed in sequence when the server is first started.  tmux
  
 loads configuration files once when the server process has
 started.  The source-file command may be used to load a file
 later.

 tmux shows any error messages from commands in configuration
 files in the first session created, and continues to process the
 rest of the configuration file.

Sometimes you don't actually want your customary mancave full of
windows running applications like text editor, or tail --follow -ing
logs, or dedicated shell window for backgrounding fifty man pages or
whatever.

Sometimes you just want your terminal multiplexer to start up a plain
old one-window session --a brand new one-- and attach it to your
terminal.

And that is exactly what happens when you invoke tmux with no
arguments, like this:

 $ tmux

But first, before it can give you your plain-old one-window session,
(if the your user's tmux server isn't already started) it has to start
the server up, so that the session can be managed. And it is at *that*
point, server start-up time, that your ~/.tmux.conf file gets read.

If you've specified a mancave session in there, a mancave session will
be started for you. Whatever is in ~/.tmux.conf is just part of
setting up the server.

And then tmux can go about doing the specific task that the user who
issued plain old

 $ tmux

asked it to do: create a plain-old one-window session and attach it to
your terminal.


but your setup works, and thank you very much for that.


You are as surprised as I was/am.


I would have never been able to think of such a variant.


Me neither! It was just hiding under /usr/share/doc/tmux,
treacherously, in obfuscated form!


And when I detach it, I can resume it again with the same command.

I based the config file above off the following example config, after
some hunting around in the man page.

  $ tail -n12 /usr/share/doc/tmux/example_tmux.conf
  # Create a single default session, because a session is created here, tmux
  # should be started with "tmux attach" rather than "tmux new"


Well I never!

I tried the new-win

Re: from screen to tmux

2020-06-22 Thread Victor Sudakov
davidson wrote:
> > 
> > I'm trying to switch from screen to tmux and for the life of me cannot
> > make it work the way I like. I have screen create multiple windows on
> > startup, by the following lines in ~/screenrc:
> > 
> > screen -t localhost 0
> > screen -t foo 1
> > screen -t bar 2
> > screen -t mail 3
> > select 0
> > 
> > I've tried multiple variants of ~/.tmux.conf and cannot make it start
> > with 4 windows. Tried different combinations of new-session, new-window,
> > attach-session, select-window and whatever, but when I run tmux, I just
> > see a single window.
> > 
> > What would be the equivalent of the above screen commands?
> 
> The first line below changes the command key from Ctrl-b to Ctrl-a, to
> emulate Gnu screen.
> 
>   $ cat ~/.tmux.conf
>   set-option -g prefix C-a

This is a nice feature, but not quite sufficient. You won't be able to
send a literal C-a to the terminal if you have just this one line.

I have 3 lines doing the same job:

set-option -g prefix C-a
unbind-key C-b
bind-key C-a send-prefix


>   new-session -nlocalhost -sMyFirstTmuxSession
>   new-window -d -nfoo -t1
>   new-window -d -nbar -t2
>   new-window -d -nmail -t3
> 
> I started my first session with this command:
> 
>   $ tmux attach

It is quite counter-intuitive to start a *first* session with "tmux attach", 
but your setup works, and thank you very much for that. I would have never
been able to think of such a variant.

> 
> And when I detach it, I can resume it again with the same command.
> 
> I based the config file above off the following example config, after
> some hunting around in the man page.
> 
>   $ tail -n12 /usr/share/doc/tmux/example_tmux.conf
>   # Create a single default session, because a session is created here, tmux
>   # should be started with "tmux attach" rather than "tmux new"

Well I never! 

I tried the new-window command in .tmux.conf, but it always created
windows somewhere below the event horizon.

Thank you again!

-- 
Victor Sudakov,  VAS4-RIPE, VAS47-RIPN
2:5005/49@fidonet http://vas.tomsk.ru/


signature.asc
Description: PGP signature


Re: from screen to tmux

2020-06-22 Thread davidson

On Mon, 22 Jun 2020 Victor Sudakov wrote:

Dear Colleagues,

I'm trying to switch from screen to tmux and for the life of me cannot
make it work the way I like. I have screen create multiple windows on
startup, by the following lines in ~/screenrc:

screen -t localhost 0
screen -t foo 1
screen -t bar 2
screen -t mail 3
select 0

I've tried multiple variants of ~/.tmux.conf and cannot make it start
with 4 windows. Tried different combinations of new-session, new-window,
attach-session, select-window and whatever, but when I run tmux, I just
see a single window.

What would be the equivalent of the above screen commands?


The first line below changes the command key from Ctrl-b to Ctrl-a, to
emulate Gnu screen.

  $ cat ~/.tmux.conf
  set-option -g prefix C-a
  new-session -nlocalhost -sMyFirstTmuxSession
  new-window -d -nfoo -t1
  new-window -d -nbar -t2
  new-window -d -nmail -t3

I started my first session with this command:

  $ tmux attach

And when I detach it, I can resume it again with the same command.

I based the config file above off the following example config, after
some hunting around in the man page.

  $ tail -n12 /usr/share/doc/tmux/example_tmux.conf
  # Create a single default session, because a session is created here, tmux
  # should be started with "tmux attach" rather than "tmux new"
  new -d -s0 -nirssi 'exec irssi'
  set -t0:0 monitor-activity on
  set  -t0:0 aggressive-resize on
  neww -d -ntodo 'exec emacs ~/TODO'
  setw -t0:1 aggressive-resize on
  neww -d -nmutt 'exec mutt'
  setw -t0:2 aggressive-resize on
  neww -d
  neww -d
  neww -d

The modifications were mainly to replace all the aliases in the
/usr/share/doc/ example with the corresponding full command
names. (Seems a bit weird to put abbreviated aliases in a example
meant to provide documentation.)

--
Firstly, you must always implicitly obey orders, without attempting to
form any opinion of your own respecting their propriety. Secondly, you
must consider every man your enemy who speaks ill of your king; and
thirdly, you must hate a Frenchman, as you do the devil. --H. Nelson



Re: from screen to tmux

2020-06-22 Thread Victor Sudakov
Brian wrote:
> On Mon 22 Jun 2020 at 17:46:40 +0700, Victor Sudakov wrote:
> 
> > Dear Colleagues,
> > 
> > I'm trying to switch from screen to tmux and for the life of me cannot
> > make it work the way I like. I have screen create multiple windows on
> > startup, by the following lines in ~/screenrc:
> > 
> > screen -t localhost 0
> > screen -t foo 1
> > screen -t bar 2
> > screen -t mail 3
> > select 0
> > 
> > I've tried multiple variants of ~/.tmux.conf and cannot make it start
> > with 4 windows. Tried different combinations of new-session, new-window,
> > attach-session, select-window and whatever, but when I run tmux, I just
> > see a single window.
> > 
> > What would be the equivalent of the above screen commands?
> 
> A search with
> 
>   tmux start three windows

It is not news for me that Google exists :-)

> brings up items that look like they would be useful.

They look so but in fact they are not. They are mostly about starting
several tmux windows from a wrapper script like in
https://stackoverflow.com/questions/5609192/how-to-set-up-tmux-so-that-it-starts-up-with-specified-windows-opened#5752901
and https://gist.github.com/todgru/6224848 and others.

I'm sure this should be possible from ~/.tmux.conf but the limited
variants I've found online did not work for me.

If from personal experience you have a working solution, I'd be most
grateful.


-- 
Victor Sudakov,  VAS4-RIPE, VAS47-RIPN
2:5005/49@fidonet http://vas.tomsk.ru/


signature.asc
Description: PGP signature


Re: from screen to tmux

2020-06-22 Thread Brian
On Mon 22 Jun 2020 at 17:46:40 +0700, Victor Sudakov wrote:

> Dear Colleagues,
> 
> I'm trying to switch from screen to tmux and for the life of me cannot
> make it work the way I like. I have screen create multiple windows on
> startup, by the following lines in ~/screenrc:
> 
> screen -t localhost 0
> screen -t foo 1
> screen -t bar 2
> screen -t mail 3
> select 0
> 
> I've tried multiple variants of ~/.tmux.conf and cannot make it start
> with 4 windows. Tried different combinations of new-session, new-window,
> attach-session, select-window and whatever, but when I run tmux, I just
> see a single window.
> 
> What would be the equivalent of the above screen commands?

A search with

  tmux start three windows

brings up items that look like they would be useful.

-- 
Brian.



Re: from screen to tmux

2020-06-22 Thread Kenneth Parker
On Mon, Jun 22, 2020, 6:47 AM Victor Sudakov  wrote:

> Dear Colleagues,
>
> I'm trying to switch from screen to tmux and for the life of me cannot
> make it work the way I like. I have screen create multiple windows on
> startup, by the following lines in ~/screenrc:
>
> screen -t localhost 0
> screen -t foo 1
> screen -t bar 2
> screen -t mail 3
> select 0
>
> I've tried multiple variants of ~/.tmux.conf and cannot make it start
> with 4 windows. Tried different combinations of new-session, new-window,
> attach-session, select-window and whatever, but when I run tmux, I just
> see a single window.
>
> What would be the equivalent of the above screen commands?
>

First, did you install tmux?  ("apt install tmux")?

And then, you begin with the "tmux" command.

Inside the session, cntl-b controls the session.  ("cntl-b ?"  for help).

Hope this helps.

-- 
> Victor Sudakov,  VAS4-RIPE, VAS47-RIPN
> 2:5005/49@fidonet http://vas.tomsk.ru/


Best regards,

Kenneth Parker


from screen to tmux

2020-06-22 Thread Victor Sudakov
Dear Colleagues,

I'm trying to switch from screen to tmux and for the life of me cannot
make it work the way I like. I have screen create multiple windows on
startup, by the following lines in ~/screenrc:

screen -t localhost 0
screen -t foo 1
screen -t bar 2
screen -t mail 3
select 0

I've tried multiple variants of ~/.tmux.conf and cannot make it start
with 4 windows. Tried different combinations of new-session, new-window,
attach-session, select-window and whatever, but when I run tmux, I just
see a single window.

What would be the equivalent of the above screen commands?

-- 
Victor Sudakov,  VAS4-RIPE, VAS47-RIPN
2:5005/49@fidonet http://vas.tomsk.ru/


signature.asc
Description: PGP signature