zsh-users
 help / color / mirror / Atom feed
* zsh : launch tmux in just one terminal
@ 2021-10-01 10:47 zzapper
  2021-10-01 13:25 ` Marc Chantreux
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: zzapper @ 2021-10-01 10:47 UTC (permalink / raw)
  To: Zsh-Users List

hi

I would like to my first invocation of a 'Gnome terminal' on Linux mint  
to automatically launch tmux but not for any subsequent consoles .


My more generic question is how can consoles share information?


Best regards

David Rayner




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: zsh : launch tmux in just one terminal
  2021-10-01 10:47 zsh : launch tmux in just one terminal zzapper
@ 2021-10-01 13:25 ` Marc Chantreux
  2021-10-01 13:30 ` Steve Dondley
  2021-10-01 16:54 ` zzapper
  2 siblings, 0 replies; 15+ messages in thread
From: Marc Chantreux @ 2021-10-01 13:25 UTC (permalink / raw)
  Cc: Zsh-Users List

hello,

> I would like to my first invocation of a 'Gnome terminal' on Linux mint  to
> automatically launch tmux but not for any subsequent consoles

> My more generic question is how can consoles share information?

They just don't: consoles are just devices, not programs.

The way i deal with it is to create specific way to call terminal via
desktop files.

in my /home/mc/.local/share/applications, i have

---[ tmux_attach.desktop
     [Desktop Entry]
     Comment=terminal multiplexer
     Exec=tilix -e tmux att
     Icon=mksh32
     Name=attach tmux session
     Type=Application
---[ tmux_back.desktop
     [Desktop Entry]
     Comment=terminal multiplexer
     Exec=tilix -e zsh -ic 'c&&tmux'
     Icon=mksh32
     Name=cd back with tmux
     Type=Application
---[ tmux_session.desktop
     [Desktop Entry]
     Comment=terminal multiplexer
     Name=new tmux session
     Exec=tilix -e tmux
     Icon=mksh32
     Type=Application

Note 1: c is just a command i wrote to navigate in a MRU directories list.
it's basically cd $( fzf < ~/.was-pwd )

regards
marc


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: zsh : launch tmux in just one terminal
  2021-10-01 10:47 zsh : launch tmux in just one terminal zzapper
  2021-10-01 13:25 ` Marc Chantreux
@ 2021-10-01 13:30 ` Steve Dondley
  2021-10-01 16:54 ` zzapper
  2 siblings, 0 replies; 15+ messages in thread
From: Steve Dondley @ 2021-10-01 13:30 UTC (permalink / raw)
  To: zsh-users

On 2021-10-01 06:47 AM, zzapper wrote:
> hi
> 
> I would like to my first invocation of a 'Gnome terminal' on Linux
> mint  to automatically launch tmux but not for any subsequent consoles
> .
> 
> 
> My more generic question is how can consoles share information?
> 
> 
> Best regards
> 
> David Rayner

I'm not sure I completely understand what you are trying to do. But it 
sounds like you want to detect if tmux is already running. I'd run a 
simple script when the terminal starts up using this feature: 
https://superuser.com/a/591333


  The script will detect if the tmux process is running by grepping the 
output of the 'ps' command and launch tmux if it's not already running.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: zsh : launch tmux in just one terminal
  2021-10-01 10:47 zsh : launch tmux in just one terminal zzapper
  2021-10-01 13:25 ` Marc Chantreux
  2021-10-01 13:30 ` Steve Dondley
@ 2021-10-01 16:54 ` zzapper
  2021-10-01 17:19   ` Michael Klemm
  2 siblings, 1 reply; 15+ messages in thread
From: zzapper @ 2021-10-01 16:54 UTC (permalink / raw)
  To: zsh-users


Thanks for both answers

this seems to be what I need

if pgrep "tmux" > /dev/null ; then echo "Running" ; else echo "Stopped" ; fi

>
>
> Best regards
>
> David Rayner
>
>
>


^ permalink raw reply	[flat|nested] 15+ messages in thread

* RE: zsh : launch tmux in just one terminal
  2021-10-01 16:54 ` zzapper
@ 2021-10-01 17:19   ` Michael Klemm
  2021-10-01 17:43     ` Bart Schaefer
  0 siblings, 1 reply; 15+ messages in thread
From: Michael Klemm @ 2021-10-01 17:19 UTC (permalink / raw)
  To: zzapper, zsh-users

[-- Attachment #1: Type: text/plain, Size: 533 bytes --]

Hi,

> -----Original Message-----
> From: zsh-users-request@zsh.org <zsh-users-request@zsh.org> On Behalf Of
> zzapper
> Sent: Freitag, 1. Oktober 2021 18:55
> Thanks for both answers
>
> this seems to be what I need
>
> if pgrep "tmux" > /dev/null ; then echo "Running" ; else echo "Stopped" ;
> fi

That will only work if you're the only user of the system, who has tmux 
processes.  On multi-user machine with several tmux instances running for 
different users, pgrep tmux will also match those.

Kind regards,
        -michael


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 4429 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: zsh : launch tmux in just one terminal
  2021-10-01 17:19   ` Michael Klemm
@ 2021-10-01 17:43     ` Bart Schaefer
  2021-10-01 20:16       ` Ray Andrews
  0 siblings, 1 reply; 15+ messages in thread
From: Bart Schaefer @ 2021-10-01 17:43 UTC (permalink / raw)
  To: Michael Klemm; +Cc: zzapper, zsh-users

On Fri, Oct 1, 2021 at 10:19 AM Michael Klemm <michael@dontknow.de> wrote:
>
> > if pgrep "tmux" > /dev/null ; then echo "Running" ; else echo "Stopped" ;
> > fi
>
> On multi-user machine with several tmux instances running for
> different users, pgrep tmux will also match those.

Just make it:  pgrep -u $USER tmux


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: zsh : launch tmux in just one terminal
  2021-10-01 17:43     ` Bart Schaefer
@ 2021-10-01 20:16       ` Ray Andrews
  2021-10-01 20:34         ` zzapper
  0 siblings, 1 reply; 15+ messages in thread
From: Ray Andrews @ 2021-10-01 20:16 UTC (permalink / raw)
  To: zsh-users

On 2021-10-01 10:43 a.m., Bart Schaefer wrote:
>
> Just make it:  pgrep -u $USER tmux
>
If it's not too far off topic, what's the advantage of tmux over just a 
whole bunch of xterms?



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: zsh : launch tmux in just one terminal
  2021-10-01 20:16       ` Ray Andrews
@ 2021-10-01 20:34         ` zzapper
  2021-10-01 20:53           ` Steve Dondley
  2021-10-01 23:03           ` Ray Andrews
  0 siblings, 2 replies; 15+ messages in thread
From: zzapper @ 2021-10-01 20:34 UTC (permalink / raw)
  To: zsh-users


On 01/10/2021 21:16, Ray Andrews wrote:
> On 2021-10-01 10:43 a.m., Bart Schaefer wrote:
>>
>> Just make it:  pgrep -u $USER tmux
>>
> If it's not too far off topic, what's the advantage of tmux over just 
> a whole bunch of xterms?
>
>
Well it's a kind of poor-man's multi-screen. I can be seeing the result 
of a bc in one split, a grep in another, help file in a third, or I can 
have 2 zsh splits and one bash.

It helps alleviate the 'which xterm was I using problem'.

I could also have a tmux for one project and then jump to a tmux for a 
second project


zzapper



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: zsh : launch tmux in just one terminal
  2021-10-01 20:34         ` zzapper
@ 2021-10-01 20:53           ` Steve Dondley
  2021-10-01 23:06             ` Ray Andrews
  2021-10-01 23:03           ` Ray Andrews
  1 sibling, 1 reply; 15+ messages in thread
From: Steve Dondley @ 2021-10-01 20:53 UTC (permalink / raw)
  To: zzapper; +Cc: zsh-users

On 2021-10-01 04:34 PM, zzapper wrote:
> On 01/10/2021 21:16, Ray Andrews wrote:
>> On 2021-10-01 10:43 a.m., Bart Schaefer wrote:
>>> 
>>> Just make it:  pgrep -u $USER tmux
>>> 
>> If it's not too far off topic, what's the advantage of tmux over just 
>> a whole bunch of xterms?

One huge advantage is the ability to switch very quickly between 
different terminals. This is great when you have a lot of vim terminals 
open when you are doing development work. You can also group the 
different terminals into windows and the windows into sessions, offering 
an insane amount of organization. Organizing let's say 50 different 
shells is a breeze.

It's especially useful when you ssh into another machine. You run a tmux 
session on the remote machine. If you get disconnected or power your 
local machine down, you can log back in and be right back where you 
were. This can also be done locally with a plugin, tmux resurrect. So if 
your computer goes down, your terminals will be right there when you 
fire up tmux so you can jump back into working.

There's many more advantages, but these are the big ones.



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: zsh : launch tmux in just one terminal
  2021-10-01 20:34         ` zzapper
  2021-10-01 20:53           ` Steve Dondley
@ 2021-10-01 23:03           ` Ray Andrews
  1 sibling, 0 replies; 15+ messages in thread
From: Ray Andrews @ 2021-10-01 23:03 UTC (permalink / raw)
  To: zsh-users

On 2021-10-01 1:34 p.m., zzapper wrote:
>
> It helps alleviate the 'which xterm was I using problem'.
>
> I could also have a tmux for one project and then jump to a tmux for a 
> second project
>
>
> zzapper
>
Thanks.  I've never felt anything missing using just xterms, but you 
give me some ideas.



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: zsh : launch tmux in just one terminal
  2021-10-01 20:53           ` Steve Dondley
@ 2021-10-01 23:06             ` Ray Andrews
  2021-10-02  4:52               ` Steve Dondley
  0 siblings, 1 reply; 15+ messages in thread
From: Ray Andrews @ 2021-10-01 23:06 UTC (permalink / raw)
  To: zsh-users

On 2021-10-01 1:53 p.m., Steve Dondley wrote:
> On 2021-10-01 04:34 PM, zzapper wrote:
>> On 01/10/2021 21:16, Ray Andrews wrote:
>>> On 2021-10-01 10:43 a.m., Bart Schaefer wrote:
>>>>
>>>> Just make it:  pgrep -u $USER tmux
>>>>
>>> If it's not too far off topic, what's the advantage of tmux over 
>>> just a whole bunch of xterms?
>
> One huge advantage is the ability to switch very quickly between 
> different terminals. This is great when you have a lot of vim 
> terminals open when you are doing development work. You can also group 
> the different terminals into windows and the windows into sessions, 
> offering an insane amount of organization. Organizing let's say 50 
> different shells is a breeze.

Cool.  I rarely go past five, but maybe tmux is the way to go.



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: zsh : launch tmux in just one terminal
  2021-10-01 23:06             ` Ray Andrews
@ 2021-10-02  4:52               ` Steve Dondley
  2021-10-02 14:40                 ` Ray Andrews
  0 siblings, 1 reply; 15+ messages in thread
From: Steve Dondley @ 2021-10-02  4:52 UTC (permalink / raw)
  To: Ray Andrews; +Cc: zsh-users


> Cool.  I rarely go past five, but maybe tmux is the way to go.

Yeah, it's definitely worth at least knowing about even with just 5 
terminals, especially if you strive to keep your hands off the mouse to 
be more efficient.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: zsh : launch tmux in just one terminal
  2021-10-02  4:52               ` Steve Dondley
@ 2021-10-02 14:40                 ` Ray Andrews
  2021-10-02 16:04                   ` Steve Dondley
  0 siblings, 1 reply; 15+ messages in thread
From: Ray Andrews @ 2021-10-02 14:40 UTC (permalink / raw)
  To: zsh-users

On 2021-10-01 9:52 p.m., Steve Dondley wrote:
>
>> Cool.  I rarely go past five, but maybe tmux is the way to go.
>
> Yeah, it's definitely worth at least knowing about even with just 5 
> terminals, especially if you strive to keep your hands off the mouse 
> to be more efficient.
>
I wrote a program that jumps my mouse pointer from one terminal to the 
next via hotkeys.  Yeah, when you're in terminal mode, having to reach 
for the mouse just to move from one to the other is really annoying. 
Sounds like tmux handles this itself, but will it jump between 
monitors?  And my program works regardless of the running applications 
so whereas it mostly for use in terminals I can jump between, say a 
browser and my email too.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: zsh : launch tmux in just one terminal
  2021-10-02 14:40                 ` Ray Andrews
@ 2021-10-02 16:04                   ` Steve Dondley
  2021-10-02 19:09                     ` Ray Andrews
  0 siblings, 1 reply; 15+ messages in thread
From: Steve Dondley @ 2021-10-02 16:04 UTC (permalink / raw)
  To: Ray Andrews; +Cc: zsh-users


> I wrote a program that jumps my mouse pointer from one terminal to the
> next via hotkeys.  Yeah, when you're in terminal mode, having to reach
> for the mouse just to move from one to the other is really annoying.
> Sounds like tmux handles this itself, but will it jump between
> monitors?  And my program works regardless of the running applications
> so whereas it mostly for use in terminals I can jump between, say a
> browser and my email too.

You can have multiple tmux sessions on one computer. So you culd 
dedicate terminal "A" to tmux session "A" and have terminal "B" show 
tmux session "B" and just use hot keys to switch between them like you 
currently do.

And tmux is fully scriptable. So let's say you want to send a command 
from one pane in session A to another pane in session B, you can do this 
with a tmux hotkey without even leaving the current terminal. It's very 
powerful. I've used feature when I do testing. I'll punch a key and it 
will test the code in the current pane in a completely different 
terminal window running in a different tmux session.

I'm on a mac and I use iterm, which is just a terminal with more bells 
and whistles. I have two monitors. I typically have 3 terminal windows 
open: a vim session open for taking notes, a zsh session for running 
taskwarrior commands, and one with tmux open for all my coding and 
server administration. Within the session, you can have multiple 
windows. I like to use windows for my different projects. So if I want 
to switch to project "A", I hit a tmux hot key to jump to window "A" and 
all the important files are right there, already open in vim and ready 
for editing. Each file is in its own tmux pane, which is running it's 
own separate shell.

At any rate, my notes and tasks are on one display, the tmux session is 
full screen on the other. I use simple hot keys to change focus from one 
terminal window to the other. For other applications like my browser, I 
have hotkeys for those as well.

Well, that's probably more than you wanted to know. Like with anything, 
only you can decide if using tmux is worth the investment of time in 
learning it. If this is what you do for a living, then yeah, you should 
definitely look into tmux as it will likely pay off. If you're more of a 
casual user and just like puttering around on your computer for fun are 
writing simple scripts and issuing a few dozen commands here and there 
over the course of a day, it's probably overkill.



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: zsh : launch tmux in just one terminal
  2021-10-02 16:04                   ` Steve Dondley
@ 2021-10-02 19:09                     ` Ray Andrews
  0 siblings, 0 replies; 15+ messages in thread
From: Ray Andrews @ 2021-10-02 19:09 UTC (permalink / raw)
  To: zsh-users

On 2021-10-02 9:04 a.m., Steve Dondley wrote:
>
>
> Well, that's probably more than you wanted to know.
I appreciate it Steve.  Yeah, I'm mostly pretty lightweight but every 
now and then I dive in and get my hands dirty.  I'll keep what you've 
said in mind if my projects ever get that demanding.



^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2021-10-02 19:10 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-01 10:47 zsh : launch tmux in just one terminal zzapper
2021-10-01 13:25 ` Marc Chantreux
2021-10-01 13:30 ` Steve Dondley
2021-10-01 16:54 ` zzapper
2021-10-01 17:19   ` Michael Klemm
2021-10-01 17:43     ` Bart Schaefer
2021-10-01 20:16       ` Ray Andrews
2021-10-01 20:34         ` zzapper
2021-10-01 20:53           ` Steve Dondley
2021-10-01 23:06             ` Ray Andrews
2021-10-02  4:52               ` Steve Dondley
2021-10-02 14:40                 ` Ray Andrews
2021-10-02 16:04                   ` Steve Dondley
2021-10-02 19:09                     ` Ray Andrews
2021-10-01 23:03           ` Ray Andrews

zsh-users

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.vuxu.org/zsh-users

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 zsh-users zsh-users/ https://inbox.vuxu.org/zsh-users \
		zsh-users@zsh.org
	public-inbox-index zsh-users

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.users


code repositories for the project(s) associated with this inbox:

	https://git.vuxu.org/mirror/zsh/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git