I think you want bash's "preexec" hook, although I am not sure exactly how
to use it. That is how iTerm2 sends its "before command" escape sequences
and whatnot.

As far as doing it in tmux goes I don't really know how screen's
implementation works but I don't want to encode special stuff for bash, zsh
etc in tmux so I'm thinking of a couple of possibilities.

Perhaps an option to say "when you see X escape sequence, match the rest of
this line against this regex and use the first submatch".

Or it might be more flexible just to store the rest of the line in a
variable rather than actually renaming the window, then you could put it in
window-status-format or status-left or automatic-rename-format or anything
else with whatever transformations you like.

But if you can do it with the existing \033k then it hardly seems necessary.



On Tue, 1 Dec 2020, 20:05 , <[email protected]> wrote:

> Well Nicholas, I thought I should wait, perhaps someone would have a
> better ideas. Then I saw in github who you are! So nothing more to expect
> :)
>
> I'll search for a solution through bash, if I find anything I'll post
> it. May I make a humble request for this feature, GNU Screen's
> shelltitle like behaviour to be added some time in the future? It's
> immediate and precise (for my tastes at least).
>
> Thanx for the feedback and the nice app.
>
>
> Στις 1/12/20 9:09 μ.μ., ο/η Nicholas Marriott έγραψε:
> > Maybe bash has a way to get the command and print the sequence after you
> > press Enter?
> >
> >
> >
> > On Tue, 1 Dec 2020, 19:01 Nicholas Marriott,
> > <[email protected] <mailto:[email protected]>>
> wrote:
> >
> >     tmux only supports renaming the window with \033k, what you rename
> >     it to is up to you.
> >
> >
> >
> >     On Tue, 1 Dec 2020, 18:56 , <[email protected]
> >     <mailto:[email protected]>> wrote:
> >
> >         I need the something in between to be the command I typed in
> shell.
> >
> >         The configuration in rc file of GNU Screen is:
> >         shelltitle "$ |bash"
> >
> >         so whatever follows $ sign (whatever typed before hitting enter)
> is
> >         copied in between \033k and the \033\\ and the desired label is
> set.
> >         Else you get 'bash'. I think that's how it works, not certain,
> >         but it works.
> >
> >
> >         Στις 1/12/20 8:36 μ.μ., ο/η Nicholas Marriott έγραψε:
> >          > You are renaming it to an empty name, you need to put
> >         something in
> >          > between the \033k and the \033\\.
> >          >
> >          >
> >          > On Tue, 1 Dec 2020 at 16:49, <[email protected]
> >         <mailto:[email protected]>
> >          > <mailto:[email protected] <mailto:[email protected]>>> wrote:
> >          >
> >          >     Greetings,
> >          >
> >          >     For my preferences, tmux's automatic rename is not
> >         convenient. If for
> >          >     example I execute Ranger, a python file manager, I see
> >         'python' in the
> >          >     label instead of 'ranger'. Also, the name change is not
> >         immediate, a
> >          >     refresh is needed, starting and quiting.
> >          >
> >          >     My tmux settings:
> >          >
> >          >     set -g automatic-rename on
> >          >     set -g automatic-rename-format "#{pane_current_command}"
> >          >
> >          >     So I'm trying to simulate GNU Screen's shelltitle feature
> >         in tmux, where
> >          >     the command entered in shell (for example ranger) is
> >         shown, not the app
> >          >     running (ie python). It's accurate and immediate, no need
> >         to wait for
> >          >     refresh. It also returns to 'bash' immediately, after
> >         quitting app.
> >          >
> >          >     In tmux manual I saw that it is possible to be done
> >         screen's way:
> >          >     set -g allow-rename on
> >          >
> >          >     and changing bash prompt. I already have this in .bashrc
> >         for screen:
> >          >     case "$TERM" in
> >          >     screen*|tmux*)
> >          >     PS1="\n\e[7m\t \e[1m\w \e[m\n\n"'\[\033k\033\\\]''\$ '
> >          >
> >          >     I also tried,
> >          >     PROMPT_COMMAND='printf "\033k\033\134"'
> >          >
> >          >     as in tmux manual
> >          >     (the exact is PROMPT_COMMAND="printf
> >         '\033k\033\\';"${PROMPT_COMMAND} )
> >          >
> >          >     The result I get is just an asterisk (*) which doesn't
> >         change.
> >          >
> >          >     Any ideas how to achieve shelltitle's behaviour?
> >          >     tmux version 2.8 on Debian
> >          >
> >          >     Thank you in advance
> >          >
> >          >     --
> >          >     You received this message because you are subscribed to
> >         the Google
> >          >     Groups "tmux-users" group.
> >          >     To unsubscribe from this group and stop receiving emails
> >         from it,
> >          >     send an email to [email protected]
> >         <mailto:tmux-users%[email protected]>
> >          >     <mailto:tmux-users%[email protected]
> >         <mailto:tmux-users%[email protected]>>.
> >          >     To view this discussion on the web, visit
> >          >
> >
> https://groups.google.com/d/msgid/tmux-users/d114db31-3962-9c0c-b809-1696e813d14f%40gmx.com
> >         <
> https://groups.google.com/d/msgid/tmux-users/d114db31-3962-9c0c-b809-1696e813d14f%40gmx.com
> >
> >          >
> >           <
> https://groups.google.com/d/msgid/tmux-users/d114db31-3962-9c0c-b809-1696e813d14f%40gmx.com
> <
> https://groups.google.com/d/msgid/tmux-users/d114db31-3962-9c0c-b809-1696e813d14f%40gmx.com
> >>.
> >          >
> >
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"tmux-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/tmux-users/CAEdLfcG9zS%3D5c%2B4-wM5APd6Uw9dn-D3L8VPrsnTOffMq%2BZ34ow%40mail.gmail.com.

Reply via email to