Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Mon 22 Jul 2019, 12:41
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Utilities
Tmux
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [13 Posts]  
Author Message
aragon

Joined: 15 Oct 2007
Posts: 1698
Location: Germany

PostPosted: Thu 24 Sep 2009, 09:30    Post subject:  Tmux
Subject description: Terminal Multiplexer
 

Home: http://tmux.sourceforge.net/
Version: 1.7
Quote:
tmux is a "terminal multiplexer", it enables a number of terminals (or windows) to be accessed and controlled from a single terminal. tmux is intended to be a simple, modern, BSD-licensed alternative to programs such as GNU screen.

it is highly recommended to read the manpage in /usr/share/doc .

extract:
Tmux may be controlled from an attached client by using a key combination of a prefix key, `C-b' (Ctrl-b) by default, followed by a command key.

Some of the default key bindings are:
Code:
c    Create a new window.
d    Detach the current client.
l    Move to the previously selected window.
n    Change to the next window.
p    Change to the previous window.
&    Kill the current window.
,    Rename the current window.
?    List all key bindings.


Compiled and tested in 4.31.

aragon
tmux-1.7.pet
Description 
pet

 Download 
Filename  tmux-1.7.pet 
Filesize  168.33 KB 
Downloaded  797 Time(s) 

_________________
PUPPY SEARCH: http://wellminded.com/puppy/pupsearch.html

Last edited by aragon on Mon 18 Feb 2013, 09:39; edited 1 time in total
Back to top
View user's profile Send private message 
aragon

Joined: 15 Oct 2007
Posts: 1698
Location: Germany

PostPosted: Mon 18 Feb 2013, 04:19    Post subject:  

uploaded new version. see first post.

aragon

_________________
PUPPY SEARCH: http://wellminded.com/puppy/pupsearch.html
Back to top
View user's profile Send private message 
sc0ttman


Joined: 16 Sep 2009
Posts: 2691
Location: UK

PostPosted: Wed 20 Feb 2013, 15:12    Post subject:  

How do I change the modifier used to resize windows? It is ALT by default...

Currently, I can only resize windows in tmux in a terminal emulator, not when I actually drop out of X - because the ALT key is used to switch ttys (or something!) ... So resizing doesn't work, instead, I am sent to a login page ... (Hope I'm being clear!)

_________________
Pkg, mdsh, Woofy, Akita Linux, VLC-GTK
Back to top
View user's profile Send private message 
aragon

Joined: 15 Oct 2007
Posts: 1698
Location: Germany

PostPosted: Wed 20 Feb 2013, 15:51    Post subject:  

hi scottman,please look at this exmple

https://github.com/myfreeweb/dotfiles/blob/master/tmux.conf

for the resize-pane, to get an impression, how it works.

aragon

_________________
PUPPY SEARCH: http://wellminded.com/puppy/pupsearch.html
Back to top
View user's profile Send private message 
sc0ttman


Joined: 16 Sep 2009
Posts: 2691
Location: UK

PostPosted: Wed 20 Feb 2013, 19:01    Post subject:  

thats great, cheers.
_________________
Pkg, mdsh, Woofy, Akita Linux, VLC-GTK
Back to top
View user's profile Send private message 
rufwoof


Joined: 24 Feb 2014
Posts: 3254

PostPosted: Sat 14 Jul 2018, 13:12    Post subject: Bump  

Bumping a (very) old thread.

tmux can be great for running terminal sessions on a server, disconnecting, and then reattaching again from the same or another machine - back into the exact same session on the server.

tmux activation keycode is typically ctrl-b, so after you've ssh into a remote server and ran tmux to present a terminal window, ctrl-b d will detatch the client from that. Later you might ssh back into the server again from the same or a different device, and run tmux attach ... to restore/attach back to the session again.

tmux also caters for opening up several different terminal windows, so you might for instance have one showing htop, another connected to IRC, another to news or mail ...etc. Provided the client device can ssh, then it can be a very lightweight device.

_________________
( ͡° ͜ʖ ͡°) :wq
Fatdog multi-session usb

echo url|sed -e 's/^/(c/' -e 's/$/ hashbang.sh)/'|sh
Back to top
View user's profile Send private message 
rufwoof


Joined: 24 Feb 2014
Posts: 3254

PostPosted: Thu 19 Jul 2018, 06:44    Post subject: tmux collaboration  

Say you have a lightweight (low electrical power consumption) always on device, that's hard wired to the net, maybe connected to your family TV as a monitor and that also has a keyboard attached. If that is running something like openbsd that comes with mail, web ...etc. along with X all included and sensibly configured out of the box, then one function might be to open up ssh port forwarding to that device so you or other family members might remotely ssh into it. Assuming the PC also has a sound output (speakers connected) then a family member might ssh into the box from anywhere, on any device that supports ssh (ssh supporting handhelds, phone ...etc.), and play a sound file on that 'at home' PC to draw attention to family members at home - somewhat similar to ringing a phone. They might then switch the TV over to show the terminal screen and using tmux you can both setup and use the same terminal session.

You set up a tmux session using something like tmu new-session -s somesessionname
On the terminal session that runs that they will be entered into that session.
Another family member who has ssh into the same box using the same userid can show current sessions by running tmux ls ... to list any sessions. Seeing session somesessionname is running they can then attach to that using tmux attach -t somesessionname Thereafter both are seeing the exact same terminal session, anything than any one types/runs, so the other sees that. A third or more family members could also join in a similar manner. A form of group/collaboration instant messaging type function.

If you have tmux installed, you can try it out for yourself on the same single PC/laptop. Open two terminal windows and setup a tmux session as above in one, and then connect to that tmux session using the other.

If you have a always on server that might be running a httpd web server and using the TV as its monitor, then also constantly running a tmux session for others to connect to at any time is a low additional overhead. A form of low-cost/easy message board, where you at home can leave messages in the tmux session for other family members to ssh/tmux into and see; Or where remote family members can ssh/tmux into and "ring" the home PC system to draw attention to you asking to 'chat'.

One of the primary benefits of tmux is that sessions persist. After you ssh into a box and start a tmux session then you can detatch from that (or if the link fails), and later reattach again perhaps from another location using another device ... and the session will still be running as before. Kick off a compile for instance that might take many hours using your phone ssh/tmux into your 'server', disconnect and later reconnect again and the compile will still be running (assuming it hadn't completed).

_________________
( ͡° ͜ʖ ͡°) :wq
Fatdog multi-session usb

echo url|sed -e 's/^/(c/' -e 's/$/ hashbang.sh)/'|sh
Back to top
View user's profile Send private message 
rufwoof


Joined: 24 Feb 2014
Posts: 3254

PostPosted: Sat 21 Jul 2018, 17:49    Post subject:  

If you run your browser under user (restricted), and tmux under root ... and use tmux for your docs, data, diary ....etc. then that provides a element of data protection in the event of a browser flaw/hack. It's also quite nice/usable to have just the two running, a browser full of tabs that you flip between, and alt-tab to a tmux full of windows that you flip between. calcurse calander/appointments/todo is a nice little tmux program ... as seen/used in this video https://youtu.be/EMgOIbS4_Ms
_________________
( ͡° ͜ʖ ͡°) :wq
Fatdog multi-session usb

echo url|sed -e 's/^/(c/' -e 's/$/ hashbang.sh)/'|sh
Back to top
View user's profile Send private message 
rufwoof


Joined: 24 Feb 2014
Posts: 3254

PostPosted: Thu 20 Sep 2018, 14:22    Post subject:  

Run mc in a X session and the file manager/editor supports mouse controls. tmux however doesn't, but if you add the following to your .tmux.conf
Code:
set-option -g mouse on

# make scrolling with wheels work
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'"
bind -n WheelDownPane select-pane -t= \; send-keys -M
then you can click on tmux window names to switch between windows ...etc.

The attached is pretty much my default first boot desktop (except for Firefox and mtpaint aren't running). The console also looks pretty much like the terminal pane (tmux with htop, mc, sh) - same colours etc. It's nice having the desktop (X) version also supporting mouse actions in both tmux and mc.

I used to use Libre writer mostly for documentation. Now I'm more inclined to use mc's internal editor to add text in a non distractive way, then run that through ispell to correct spellings, then add <p align="justify"> to each paragraph, and wrap that within a html table type structure (add <html><body><table><tr><td width=5%></td><td> at the top and /</td><td width=5%></td></tr></table></body></html> at the bottom. I have both of those as files so I can simple insert them. Having converted the file to html format I use a browser to view that file and then print it to a pdf file format.

tmux and mc work very well over the net, so even if you're running them remotely on a low power handheld or phone you can still access/edit/create documents in a consitent manner. With tmux you can even detatch from a tmux session and then reattach again later - even from a different device. And for collaboration two or more of you can even attach to the same session.
s1.jpg
 Description   
 Filesize   91.63 KB
 Viewed   368 Time(s)

s1.jpg


_________________
( ͡° ͜ʖ ͡°) :wq
Fatdog multi-session usb

echo url|sed -e 's/^/(c/' -e 's/$/ hashbang.sh)/'|sh
Back to top
View user's profile Send private message 
rufwoof


Joined: 24 Feb 2014
Posts: 3254

PostPosted: Mon 04 Feb 2019, 16:20    Post subject:  

Added a additional tmux window that loads on startup, and split that window to show top in the top pane, and a cpu activity chart (script) in the bottom pane. For simplicity I've made the cpu-chart.sh script integral as part of my twin script ... where the twin script that loads up tmux is ...
Code:
#!/bin/sh
#
# My tmux initialisation script to initialise tmux windows
#

export TERM=linux

# Start a X on ctrl-alt-F3 for our Xephyr/pflask container
X :1 -br -nolisten tcp -nolisten local vt3 &
sleep 3

# I've contained the terminal cpu chart script here to keep things together
cat <<'EOF' >/root/cpu-chart.sh
#!/bin/bash

# Original : https://github.com/mnmnc/cpuchart/blob/master/cpuchart.sh

# (Rufwoof) First time run if no cpu.log then shows message, ensure clean ...
if [ ! -f cpu.log ]; then
    touch cpu.log
fi

# VARIABLES
  columns=76

# FUNCTIONS #
function draw()
{
        echo -en "\033[s"
        tput cup $1 $2
        echo -en "\033[1;3$3m$4\033[0m"
        echo -en "\033[u"
}
function wipe()
{
        echo -en "\033[s"
        tput cup $1 $2
        echo -en "\033[1;31m \033[0m"
        echo -en "\033[u"
}
#############

# HIDE CURSOR AND CLEAR SCREEN #
  tput civis & clear

while true; do

    # COLLECT UPDATE
    #

    idle=`mpstat 1 1 | grep "Average" | tail -1 | sed 's/ \+/ /g' | cut -d " " -f 11 | tr -d "\n"`;

    usage=`echo "scale=0;(100-$idle)/10" |bc`;

    # BACKUP PREVIOUS DATA #
    # CUT THE OLDEST LINE  #
    cat cpu.log | tail -$columns >> temp.tmp

    # UPDATE STATS #
    if [[ $usage -eq 0 ]];
    then
            # IF USAGE LESS THEN 20% DRAW SINGLE BAR #
            echo "1" >> temp.tmp
    else
            echo $usage >> temp.tmp
    fi

    # UPDATE LOG #
    cat temp.tmp > cpu.log
    rm temp.tmp

    # DRAW GRAPH #

    var=6;
    # BEGIN FROM COLUMN 1 #
    j=1

    while read usage
    do
            # DRAW USAGE #
            for i in `seq 1 $usage`
            do
                    top=`echo "11-$usage" | bc`
                    var=`echo "11-$i"     | bc`

                    if [[ $usage -gt 3 ]]; then
                            if [[ $usage -gt 6 ]]; then
                                    if [[ $var -eq $top ]];then
                                            draw    $var $j "1" "+"
                                    else
                                            draw    $var $j "1" "|"
                                    fi
                            else
                                    if [[ $var -eq $top ]];then
                                            draw    $var $j "3" "+"
                                    else
                                            draw    $var $j "3" "|"
                                    fi
                            fi
                    else
                            if [[ $var -eq $top ]]; then
                                    draw     $var $j "2" "+"
                            else
                                    draw     $var $j "2" "|"
                            fi
                    fi
            done

            # WIPE PREVIOUS BAR REMAINNING IF THEY EXIST #
            usage=`echo "$usage+1" | bc`

            for k in `seq $usage 11`;
            do
                    var=`echo "11-$k" | bc`
                    wipe $var $j
            done

            # PROCEED TO NEXT COLUMN #
            j=`echo "$j+1" | bc`

            # ADD LATENCY IF NEEDED #
            sleep 0.1

    done < "cpu.log"
    tput cup 11 0
#
done
EOF
# Make sure it's executable
chmod +x /root/cpu-chart.sh


########
# TMUX #
########

# start a tmux session, detach
# then send commands to that before reattaching to it
# Note that C-m is carriage return (enter)

# create a tmux session called work, and deattach so we can send keys to it
# send keys to rename the first window to admin (my tput menu)

tmux new -s work -d
tmux rename-window -t work admin
tmux send-keys -t work '/root/admin' C-m

# Add another tmux window, rename it to xephyr and load Xephyr
tmux new-window -t work
tmux rename-window -t work xephyr
tmux send-keys -t work 'ewin' C-m

# Add another system monitor window, split horizontally with top and cpu-chart
tmux new-window -t work
tmux rename-window -t work Mon
tmux send-keys -t work 'top' C-m # set it to display top
tmux split-window -v
tmux send-keys -t work '/root/cpu-chart.sh' C-m # lower half set to show cpu

# and finally select which window to show first and attach to the tmux work session
tmux select-window -t work:1
tmux attach -t work

I've compiled/installed fbcat into my EasyOS now, so the following image was captured using
Code:
fbgrab -s 4 tmux.png
(i.e. entered in another tmux window and had a 4 second delay before the snapshot was taken ... i.e. enough time to flip to the tmux pane showing the top/chart before the snapshot occurred).
tmux.png
 Description   
 Filesize   6.7 KB
 Viewed   274 Time(s)

tmux.png


_________________
( ͡° ͜ʖ ͡°) :wq
Fatdog multi-session usb

echo url|sed -e 's/^/(c/' -e 's/$/ hashbang.sh)/'|sh
Back to top
View user's profile Send private message 
rufwoof


Joined: 24 Feb 2014
Posts: 3254

PostPosted: Thu 11 Apr 2019, 19:06    Post subject:  

If you set your local tmux Prefix key to backtick, then that doesn't conflict with a remote tmux (i.e. ssh into another box) that is using the standard ctrl-b tmux Prefix. I also set my local tmux menu to show at the top of screen, the opposite of the default bottom of screen

clickable thumbnail

_________________
( ͡° ͜ʖ ͡°) :wq
Fatdog multi-session usb

echo url|sed -e 's/^/(c/' -e 's/$/ hashbang.sh)/'|sh
Back to top
View user's profile Send private message 
rufwoof


Joined: 24 Feb 2014
Posts: 3254

PostPosted: Sun 05 May 2019, 06:55    Post subject:  

As a alternative to tmux, tilda terminal emulator combined with screen multiplexor works well IMO http://www.murga-linux.com/puppy/viewtopic.php?t=116073
_________________
( ͡° ͜ʖ ͡°) :wq
Fatdog multi-session usb

echo url|sed -e 's/^/(c/' -e 's/$/ hashbang.sh)/'|sh
Back to top
View user's profile Send private message 
rufwoof


Joined: 24 Feb 2014
Posts: 3254

PostPosted: Tue 04 Jun 2019, 04:47    Post subject:  

tmux prefix key (usually Ctrl-b by default, but that I like to set to backtick) followed by a window number usually flips to that window. In some setup's however doing that for window 0 doesn't work, whilst 1 onward are fine.

To skip starting from window 0 to instead start from window 1 add
Code:

set -g base-index 1
setw -g pane-base-index 1

to your .tmux.conf, and after a restart your window numbers will start from 1


_________________
( ͡° ͜ʖ ͡°) :wq
Fatdog multi-session usb

echo url|sed -e 's/^/(c/' -e 's/$/ hashbang.sh)/'|sh
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [13 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Utilities
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1895s ][ Queries: 13 (0.0239s) ][ GZIP on ]