You are not logged in.

#126 2010-11-04 22:47:18

Network_Ned
Member
From: Europe
Registered: 2010-11-04
Posts: 1
Website

Re: Anyone loving Tmux in place of Screen? Info/Tips etc. URLs I've found

falconindy wrote:

Really enjoying this over screen so far. Also using the same trick to reattach to the same session as with screen:

function t {
    if [[ `tmux -L Main ls | grep windows` ]]; then
        tmux -L Main a
    else
        tmux -L Main
    fi
}

If you'll excuse me for mentioning it, falconindy, you seem to be making this over-complicated.

Assuming you use Bash:

function t { tmux -L Main a || tmux -L Main
}

If the first command fails Bash will, upon seeing the OR operator ("||"), try the next one. If the part before the OR operator succeeds then Bash will not bother to run the second command - there is no need to, as "one or the other" has already succeeded. You will see this "||" construction widely in init.d scripts.

I'm not sure why you're bothering to name your session - I think tmux will call the session "default" by default, and try to reattach to "default" by default.

Thus this function is adequate (for me, at least):

function t { tmux a || tmux
}

Actually, I prefer to be a bit more explicit - "a" here is short for "attach" - and I also prefer to use a longer function name. IMO it's bad practice to have a command as short as a single letter, as it can be mis-pressed too easily. If you make commands and function names longer, you're less likely to issue them by mistake, and you can still use Bash auto-completion. For example, on my systems:

function tmine { tmux attach || tmux
}

could be typed by pressing the letters "tmi" then the TAB key, but this would show on the command line as "tmine" before I hit enter, so I know exactly what command I am about to run before I commit to it. Or you probably don't have any commands on your system beginning with the letters "tx", so you could call it "txra" (for "tmux-extra") and autocomplete with two letters ("tx") and a tab.

I apologise if I'm missing something, and if you have good reasons to do things this way then I hope you'll accept my apologies.

Otherwise I propose the following statement:
Making a command depend upon the output `grep` is bad practice, if you can possibly avoid it. We've all done it, but try and find a better way. I guess the reason we all do it is that we see examples like the one posted, and it works, so we follow it. But it depends on the output being unchanged in the future; grep is ideal for looking for a phone number in a bunch of text files (that's its purpose!) but if you have a command you want to run when another doesn't work, look at the exit status of the first. An alternate way to see if a command is running is to use `ps`.

Last edited by Network_Ned (2010-11-04 22:52:15)

Offline

#127 2010-11-15 19:26:28

archtaku
Member
Registered: 2010-07-02
Posts: 84

Re: Anyone loving Tmux in place of Screen? Info/Tips etc. URLs I've found

archtaku wrote:

Has anyone figured out how to move a window to a brand new session? I tried running

tmux movew -s 2 -t newsession

to move window 2 from the current session to a new session named "newsession". But I get an error that "newsession" does not exist. I had to detach, start a new session, reattach, then move the window to the new session. This also results in an unwanted first window in the new session, with the recently-moved window taking the 2nd window position.

Does anyone know if this is possible?

Offline

#128 2010-11-15 20:14:01

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: Anyone loving Tmux in place of Screen? Info/Tips etc. URLs I've found

edit: disregard.  Fixed.

Scott

Last edited by firecat53 (2010-11-15 20:19:28)

Offline

#129 2010-11-15 20:18:08

archtaku
Member
Registered: 2010-07-02
Posts: 84

Re: Anyone loving Tmux in place of Screen? Info/Tips etc. URLs I've found

firecat53 wrote:

Has anyone else noticed that if you type 'su' and anything else (- or a username), it will only accept one letter of the password and then start typing it cleartext? I noticed it in screen as well. Is this a 'su' issue in coreutils that need a bug report or a tmux/screen issue that needs a bug report? Or is it just me? smile

Scott

I tried this in tmux and could not replicate it.

Offline

#130 2010-11-15 20:25:01

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: Anyone loving Tmux in place of Screen? Info/Tips etc. URLs I've found

archtaku wrote:
archtaku wrote:

Has anyone figured out how to move a window to a brand new session? I tried running

tmux movew -s 2 -t newsession

to move window 2 from the current session to a new session named "newsession". But I get an error that "newsession" does not exist. I had to detach, start a new session, reattach, then move the window to the new session. This also results in an unwanted first window in the new session, with the recently-moved window taking the 2nd window position.

Does anyone know if this is possible?

I just asked in #tmux

Create the new session from the current one with

new -d -s $NAME

Then move the window...

Ctrl-b . $NAME

Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#131 2010-11-15 20:41:13

archtaku
Member
Registered: 2010-07-02
Posts: 84

Re: Anyone loving Tmux in place of Screen? Info/Tips etc. URLs I've found

jasonwryan wrote:

I just asked in #tmux

Create the new session from the current one with

new -d -s $NAME

Then move the window...

Ctrl-b . $NAME

Yeah, that's pretty much what I was doing in the first place, except I was detaching first to create the new session rather than creating a detached session. This still has the unwanted side-effect that the window gets moved to position 2 in the newly-created session, rather than becoming the only window in the new session. I guess this is something I could script:

movew -s session2:1 -t session2:99
movew -s session1:$windownum -t session2:1
killw -t session2:99

... and then bind a key to run-shell myscript.sh.

Offline

#132 2010-11-15 21:18:02

steve___
Member
Registered: 2008-02-24
Posts: 452

Re: Anyone loving Tmux in place of Screen? Info/Tips etc. URLs I've found

I suggest following Jason's lead and ask in #tmux on freenode.org

If you find the exact answer your after be sure to post it here.

Offline

#133 2010-11-15 21:26:30

archtaku
Member
Registered: 2010-07-02
Posts: 84

Re: Anyone loving Tmux in place of Screen? Info/Tips etc. URLs I've found

steve___ wrote:

I suggest following Jason's lead and ask in #tmux on freenode.org

If you find the exact answer your after be sure to post it here.

Certainly.

Last edited by archtaku (2010-11-15 21:26:57)

Offline

#134 2010-11-16 17:58:35

golwin
Member
From: Germany, Aachen
Registered: 2009-03-12
Posts: 35

Re: Anyone loving Tmux in place of Screen? Info/Tips etc. URLs I've found

tmux seems to be really nice, but one thing stops me from leaving screen behind: multi display mode.
In screen it's easily done with screen -x but I cannot find it for tmux. Does anyone know whether it is really missing?


arch64 | awesome | screen | ranger | vim | cmus | weechat | bitlbee

Offline

#135 2010-11-16 18:04:01

archtaku
Member
Registered: 2010-07-02
Posts: 84

Re: Anyone loving Tmux in place of Screen? Info/Tips etc. URLs I've found

golwin wrote:

tmux seems to be really nice, but one thing stops me from leaving screen behind: multi display mode.
In screen it's easily done with screen -x but I cannot find it for tmux. Does anyone know whether it is really missing?

Yep.

http://tmux.sourceforge.net/ <-----------------

Offline

#136 2010-11-16 18:14:40

golwin
Member
From: Germany, Aachen
Registered: 2009-03-12
Posts: 35

Re: Anyone loving Tmux in place of Screen? Info/Tips etc. URLs I've found

Well now, I knew that link and it's not particularly helpful wink (Or I'm being blind.)

Maybe I wasn't clear enough: Attaching my session to multiple terminals is no problem. But all of them alway display the same tmux-window. If I switch the tmux-window in one of the terminals, then it is switched in all other terminals as well. Screen allows me to display different screen-windows of the same screen-session in different terminals.


arch64 | awesome | screen | ranger | vim | cmus | weechat | bitlbee

Offline

#137 2010-11-16 18:32:07

archtaku
Member
Registered: 2010-07-02
Posts: 84

Re: Anyone loving Tmux in place of Screen? Info/Tips etc. URLs I've found

Ahh! In that case you can just create another session and group it with the first session. So, if your session is named "foo" you can run the following command:

tmux new -s bar -t foo

Then if you list your sessions you'll see something like this:

foo: 2 windows (created Tue Nov 16 12:24:55 2010) [120x39] (group 0) (attached)
bar: 2 windows (created Tue Nov 16 12:25:40 2010) [120x39] (group 0) (attached)

The "group 0" in both sessions denotes the fact that they're grouped. If you want to end (and not just detach) the second session, the only way I can think of doing so is to kill it by running tmux kill-session.

Last edited by archtaku (2010-11-16 18:32:24)

Offline

#138 2010-11-16 18:46:46

golwin
Member
From: Germany, Aachen
Registered: 2009-03-12
Posts: 35

Re: Anyone loving Tmux in place of Screen? Info/Tips etc. URLs I've found

Ah great, that seems to be the solution, thank you smile
But it still is not as good as in screen. E.g. It doesn't work good for differently sized terminal windows.

Last edited by golwin (2010-11-16 18:51:34)


arch64 | awesome | screen | ranger | vim | cmus | weechat | bitlbee

Offline

#139 2010-11-16 22:23:20

manmachine
Member
From: Athens
Registered: 2010-10-28
Posts: 62
Website

Re: Anyone loving Tmux in place of Screen? Info/Tips etc. URLs I've found

Anyone using tmux inside guake + a shell script to setup his tmux session with various windows/panes?
I'm seeing an issue with some panes set to open a file for editing or tailing a logfile:

If i exit the command being run in the pane, the term seems somehow 'corrupted', if i start typing something it may be printed on top of the command prompt etc.
Reseting the term will not fix this, but if i resize the pane manually with the appropriate tmux shortcut it will be fixed!
$Term is set to 'screen' as it should according to tmux docs. Am i missing another setting maybe?

Last edited by manmachine (2010-11-16 22:42:31)

Offline

#140 2010-11-20 18:30:29

Leonid.I
Member
From: Aethyr
Registered: 2009-03-22
Posts: 999

Re: Anyone loving Tmux in place of Screen? Info/Tips etc. URLs I've found

Forgive my ignorance, but how does TMux make authentication when unlocking the screen, if it doesn't depend on PAM (which is used by GNU Screen and Xscreensaver)?


Arch Linux is more than just GNU/Linux -- it's an adventure
pkill -9 systemd

Offline

#141 2010-11-24 00:19:24

jakob
Member
From: Berlin
Registered: 2005-10-27
Posts: 419

Re: Anyone loving Tmux in place of Screen? Info/Tips etc. URLs I've found

Woooohohaaa. How greatly straight-forward, clearly structured and well usable! Awesome!

I had various things to change due to my keyboard layout Neo2, and today I finished to change the mappings not only for hjkl in copy-mode, but also in vi-{choice,edit}. All done via :lsk -t vi-{copy,choice,edit}, man tmux and, ok, one google search. But it simply works and is so straight-forward clear. I'm just amazed.

Also with sessions: Sth as simple as I am working with of course was  possible with screen already, but I simply eschewed the pain and lived like 4 years with starting ncmpcpp by hand.

And now with this easy-to-use vertical and horizontal window splitting w/o needing to patch sources and anything. Just a dream!

Here is my config…

#################### General preferences
# set zsh as default-command for shells
set -g default-command zsh
# start window indexing at one instead of zero
set -g base-index 1
# utf8 support
set-window-option -g utf8 on
# vi-style controls in copy mode
set-option -g status-keys vi
set-window-option -g mode-keys vi
# move tmux copy buffer into x clipboard: C-y
bind-key y save-buffer /tmp/tmux-buffer \; run-shell "cat /tmp/tmux-buffer | xclip"
# History
set-option -g history-limit 5000

#################### key bindings
# once was:  $Id: screen-keys.conf,v 1.6 2010/02/02 21:34:16 nicm Exp $
# By Nicholas Marriott. Public domain.
#################### imitate screen: Use C-a instead of C-b
unbind C-b
set -g prefix C-a
bind C-a send-prefix

#################### adjust bindings for use with Neo2 http://neo-layout.org
### copy mode: lkhq replaces hjkl, j replaces q and k is already cursor-up
unbind -t vi-copy l
bind -t vi-copy l cursor-left
bind -t vi-copy h cursor-down
bind -t vi-copy q cursor-right
bind -t vi-copy j cancel
### as well in vi-edit table…
bind -c -t vi-edit l cursor-left
bind -c -t vi-edit q cursor-right
bind -c -t vi-edit h history-down
bind -c -t vi-edit j cancel
### and in vi-choice table…
bind -t vi-choice h down
bind -t vi-choice j cancel

#################### windows & panes: creation, splitting, handling, & more
### Windows
# create new window: ^C c
unbind ^C
bind ^C new-window
bind c
bind c new-window
# next window: @, o, C-a
unbind @
bind @ next-window
unbind o
bind o next-window
unbind C-a
bind C-a next-window
# prev window: ^H ^P p ^?
unbind ^H
bind ^H previous-window
unbind ^P
bind ^P previous-window
unbind p
bind p previous-window
# kill window: K k
unbind K
bind K confirm-before "kill-window"
unbind k
bind k confirm-before "kill-window"

### Panes
# More straight forward bindings for window splitting
unbind |
bind | split-window -h
bind - split-window -v
# next pane: n, C-n
unbind n
bind n select-pane -t :.+
unbind C-n
bind C-n select-pane -t :.+

### Misc
# open a url via urlview: u
bind-key u capture-pane \; save-buffer /tmp/tmux-buffer \; run-shell "$TERMINAL -e 'cat /tmp/tmux-buffer | urlview'"
# lockscreen: ^X x
unbind ^X
bind ^X lock-server
unbind x
bind x lock-server
# quit: \
unbind \
bind \ confirm-before "kill-server"
# redisplay: ^L l
unbind ^L
bind ^L refresh-client
unbind l
bind l refresh-client
# displays: *
unbind *
bind * list-clients
# detach: ^D d
unbind ^D
bind ^D detach

#################### Statusbar properties
set-option -g status-justify centre
set-option -g status-bg black
set-option -g status-fg white
set-option -g status-interval 5
set-option -g status-left '#[fg=magenta] #H' #[default]'
set-option -g status-right '#[fg=yellow]%k:%M #[fg=green]%a, %d. %b#[default] '
# Highlighting the active window in status bar
set-window-option -g window-status-current-attr bold
set-window-option -g window-status-current-fg red
# Notifying if other windows has activities
set-option -g visual-activity on
set-window-option -g monitor-activity on


#################### Window titling
set-option -g set-titles on
# program name in title only
set-option -g set-titles-string '#W'
# auto rename to currently running program
set-window-option -g automatic-rename on

#################### Session preferences
# one fullscreen session to mainly work in
new -d -sgroß
split-window -h ncmpcpp
split-window -v
neww
split-window -h -d
next-window
# one right-side session if there is something to be typed while ffox visible
new -d -srechts
neww -d

Is it possible that when selecting text in copy mode, I can't do »G« to get to the last line of the (very long) file, but only get to the last visible line borderd by my window?

Last edited by jakob (2010-11-24 00:31:48)

Offline

#142 2010-12-02 05:52:18

nXqd
Member
Registered: 2010-07-01
Posts: 173
Website

Re: Anyone loving Tmux in place of Screen? Info/Tips etc. URLs I've found

I'm thinking out run tmux as startup in specific dwm tag. And open some buffers renamed suite my need.
How can I work this ?


When you live for a strong purpose, then hard work isn't an option. It's a necessity. - Steve Pavlina
dotFiles

Offline

#143 2010-12-02 05:57:36

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: Anyone loving Tmux in place of Screen? Info/Tips etc. URLs I've found

Set a rule in config.h for tmux and then in your tmux.conf initialize the session with your required setup...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#144 2010-12-02 16:14:48

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: Anyone loving Tmux in place of Screen? Info/Tips etc. URLs I've found

@nXqd:
from config.def.h:

 { NULL,  NULL,       "Terminal",       1 << 0,       False,       -1 },
        { NULL,  NULL,       "comms",       1 << 2,       False,       -1 },
        { NULL,  NULL,       "ncmpcpp",       1 << 3,       False,       -1 },
............
static const char *termshcmd[]  = { "urxvtc", "-title", "Terminal", "-e", "tmux", "attach", "-d", "-t", "term", NULL };

part of tmux.conf:

new -s terminal -d -nterm
neww -d -nranger 'exec ranger'
neww -d -nmysql 'exec mysql -uuser -ppassword db_name'

new -s comms -d -nMutt 'exec tsocks mutt'
neww -d -nweechat 'exec tsocks weechat-curses'

That's how I do it smile
Scott

Offline

#145 2010-12-02 18:02:41

archtaku
Member
Registered: 2010-07-02
Posts: 84

Re: Anyone loving Tmux in place of Screen? Info/Tips etc. URLs I've found

jakob wrote:

Is it possible that when selecting text in copy mode, I can't do »G« to get to the last line of the (very long) file, but only get to the last visible line borderd by my window?

I just did a tmux list-keys -t vi-copy and didn't see an option that looked like it would work.

Offline

#146 2010-12-06 12:33:40

mhertz
Member
From: Denmark
Registered: 2010-06-19
Posts: 681

Re: Anyone loving Tmux in place of Screen? Info/Tips etc. URLs I've found

Sorry for newbie'sh question, but could someone please tell me what advantage using tmux gives you when working in X using a tilling WM ?

I can understand the usage from the console and VTs, where tmux works as a manual tilling wm, but I see many of you talk about urxvt and such, so I was currious about what it is that is the benefit, since if i could learn that, then i could see what i'm missing out without a terminal multiplexer and could begin use tmux like the rest of you guys!

I just read this whole thread, and there also were one that asked this question, but it was just answered by one person which didn't knew the advantage besides the ability to split windows, which isn't an advantage since manual WMs do that just fine allready...

I personally use musca and have several urxvt's opened in different split panes, and then i thought why open just one musca window and then let tmux split the panes for me instead of my WM?

Thanks in advance.

Last edited by mhertz (2010-12-06 12:36:52)

Offline

#147 2010-12-06 14:01:18

rson451
Member
From: Annapolis, MD USA
Registered: 2007-04-15
Posts: 1,233
Website

Re: Anyone loving Tmux in place of Screen? Info/Tips etc. URLs I've found

mhertz wrote:

Sorry for newbie'sh question, but could someone please tell me what advantage using tmux gives you when working in X using a tilling WM ?

Biggest advantage for me personally is the ability to run multiple things over an ssh session comfortably.  I use ratpoison at home so I'm used to the manual tiling concept, now when I'm at work I can have the same control over an ssh session and not have to open multiple ssh sessions to get things done on my server at home.


archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson

Offline

#148 2010-12-06 14:08:07

steve___
Member
Registered: 2008-02-24
Posts: 452

Re: Anyone loving Tmux in place of Screen? Info/Tips etc. URLs I've found

I'd say the two big advantages to screen/tmux are:
1) If the virtual terminal were to crash the local bash session(s) stay intact.
2) If ssh'd into a computer and if the connection were to die or if the host computer were to crash, the remote bash session(s) stay running.

Having bash sessions which are difficult to crash is huge when running programs.

Offline

#149 2010-12-07 08:29:32

mhertz
Member
From: Denmark
Registered: 2010-06-19
Posts: 681

Re: Anyone loving Tmux in place of Screen? Info/Tips etc. URLs I've found

Íf running e.g. multiple urxvt's without the urxvd deamon, then one dying urxvt shouldn't kill the others i believe...

Also, i'm not talking about the console without X or VTs and places where you don't have a WM installed, but specifically the situation where you're working in X with a tilling WM, which i believe most of you guys are in, as I can see from the apps you list that they need X(urxvt) and that I know that some of you use e.g. dwm etc.

I'm beginning to think that it's because you're using automatic tilers and then want a more manual grip on your teminal emulator tillings, which could instead be replaced by using a manual tiler to begin with...

Or is the only reason the not being able to crash multiple terminals? That's of course very important, but however which as i said i belive is the same as running multiple urxvts without running the urxvd deamon! But if not running the deamon, then the ram usage is then increasing with each new terminals opened, so are you saying that tmux prevents individual terminals from crashing and also not using more ram for each new opened terminal? If so then that's a great reason, as it's like running the urxvd deamon and still not being able to crash individual terminal sessions, but still i would love to hear if there where more reasons?

I'm sorry if this is off-topic, but i've just always wondered about this ever since i got to learn about terminal multiplexers, so if you could give me your reasons for using terminal multiplexers in X when using a tilling WM, then I would appreciate it!

Last edited by mhertz (2010-12-07 08:39:35)

Offline

#150 2010-12-07 08:40:59

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: Anyone loving Tmux in place of Screen? Info/Tips etc. URLs I've found

As steve_ and rson451 said: it is so I can have various services running in tmux (like rotrrent or irc, for example) and then connect to them remotely through ssh.

Everything else is a bonus.

And no, it is not to compensate for some desire for more manual control over terms - I'm pretty happy with dwm smile


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

Board footer

Powered by FluxBB