You are not logged in.
Could anybody point me to some material on getting tmux to load a config which would split it into panes automatically, each with an application running in them? I want to set it up like an IDE using vim.
Offline
I have a setup similar to that which I use for work. I have several email accounts I monitor using Mutt, two of which I put in split panes in the 2nd window. Here's the config for it:
# pull in global config
source $HOME/.tmux.conf
# spawn windows
new -d -s work "exec bash -i -c 'mutt'"
neww -n l3mail "exec bash -i -c 'mutt -F $HOME/.muttrc.account1"
splitw -v -p 50 -t work:2 "exec bash -i -c 'mutt -F $HOME/.muttrc.account2'"
neww 'exec bash'
setw -t work:1 monitor-activity on
setw -t work:2 monitor-activity on
selectw -t work:1
The first line under the "spawn windows" comment establishes a new session called "work". I then have a shell script that launches the environment for me:
#!/bin/bash
# Don't launch if within a tmux session already.
if [ -z "$TMUX" ]; then
# Check if there's a running server with a session named "work"
tmux has-session -t work 2>/dev/null
if [ $? -eq 0 ]; then
tmux attach -t work
else
# Attempt to generate a new session named "work" in the currently-running server
tmux source $HOME/.tmux.conf.work 2>/dev/null
if [ $? -eq 0 ]; then
tmux attach -t work
else
# Nonzero exit status means no running server. Start new server using "work" config.
tmux -f $HOME/.tmux.conf.work attach
fi
fi
else
echo "Exit tmux first, bonehead!"
fi
exit 0
Offline
As cool as that is, I have no idea on how to customize it.
Offline
Have you tried looking at my work config and comparing it to the manpage to figure it out? It's not very complicated.
Offline
Could anybody point me to some material on getting tmux to load a config which would split it into panes automatically, each with an application running in them? I want to set it up like an IDE using vim.
The wiki page has a section detailing exactly this...
Offline
The wiki page has a section detailing exactly this...
That doesn't seem to work though, it only brings up two tmux windows.
Offline
That doesn't seem to work though, it only brings up two tmux windows.
Really? It works for me - I use the same method to open three windows in a session, with the second and third windows split into multiple panes running specific applications. And all I did was use the example on that page to set it up.
Offline
new -s IDE -n Make bash
splitw -v -p 50 -t 0 Make
selectp -t 0
$ tmux -f IDE.conf attach
It doesn't appear to have a split.
Offline
That's because you aren't telling it what to split with... It needs a command with splitw, otherwise it will split it and then just close it instantaneously...
Offline
Ah, but the wiki says:
new -s SessionName -n WindowName Command
neww -n foo/bar foo
splitw -v -p 50 -t 0 bar
selectw -t 1
selectp -t 0
So I thought 'foo' and 'bar' were names.
Offline
Here is what I use at home:
new -s gesamt
splitw -h ncmpcpp
splitw -v
#neww
#splitw -h -d
#next
Here is what it does:
• Create a new session called „gesamt“
• splits it horizontally and starts ncmpcc in the newly created (i.e. the right) pane
• splits this right pane again, this time vertically
if you uncomment the last three lines, it additionally
• creates a new window (i.e. a tab)
• splits this newly created window horizontally
• switches back to the first window so I have my three-pane-setup in front of me when everything is finished.
I start my urxvt (some definitions given per .Xresources, which is the reason for the „-name“ argument) via:
urxvtc -name gesamt -e tmux attach -tgesamt &> /dev/null &
Hope this helps a bit?
Jakob
Last edited by jakob (2011-05-01 10:34:05)
Offline
Ah, after fiddling I got the setup I want, but I want to go to paths relative to the directory it's launched in. Is there an easy way to do this or will I have to create a temporary config file using a script?
Offline
Ah, after fiddling I got the setup I want, but I want to go to paths relative to the directory it's launched in. Is there an easy way to do this or will I have to create a temporary config file using a script?
Try creating session files that will set up what you want to start automatically. This will do the trick:
#!/bin/bash
# Starts tmux if it's not already running
tmux start-server
# This is a skeleton file, so replace <default> with the name you'd like to call your session
if ! $(tmux has-session -t default); then
cd /path/to/default/directory
tmux new-session -d -s default
# Commands go here, e.g. this is what I use as my default session. Read the manual page for tmux for tips :)
tmux rename-window -t default:0 'sysadmin'
tmux new-window -t default:1 -n 'music' 'ncmpcpp'
tmux new-window -t default:2 -n 'filesystem' 'ranger'
tmux new-window -t default:3 -n 'shell'
tmux select-window -t default:0
fi
# This bit is optional; uncomment it to load the session when you create it with this script.
#if [ -z $TMUX ]; then
# tmux -u attach-session -t default
#else
# tmux -u switch-client -t default
#fi
#vim:syn=sh
Drop this somewhere in your $PATH, chmod it +x, and execute it to create and switch to a session.
If you want something a bit more like an actual session manager, try tmuxinator; I based some of my code on its skeleton session.
Offline
Has anyone else had trouble using pinentry-curses with tmux? When I do, the pinentry window routinely comes up in a different tmux window (usually the farthest left), and sometimes comes up in the tty from which I ran startx.
My other option is to use gtk-2 or qt4 pinentry instead of curses, but it seems rather silly to do this when SSH'ed into a remote box, as I'd need to forward an X window just to enter my passphrase.
EDIT: Looks like it's a known issue, found this: https://bugs.g10code.com/gnupg/issue1203
Last edited by archtaku (2011-05-17 17:16:08)
Offline
I learned screen and I loved it. Then I learned tmux and I loved it even more!
Vanity of vanities, saith the Preacher, vanity of vanities; all is vanity.
What profit hath a man of all his labour which he taketh under the sun?
All the rivers run into the sea; yet the sea is not full; unto the place from whence the rivers come, thither they return again.
For in much wisdom is much grief: and he that increaseth knowledge increaseth sorrow.
Offline
Is screen flickering when updating the status bar at one second intervals while working in X and tmux being on a tty a known issue? For example, I have:
[hauzer@ ~]$ cat .tmux.conf
set-option -g default-shell /bin/bash
set-option -g history-limit 10000
set-option -g detach-on-destroy off
set-option -g message-bg colour231
set-option -g status-bg colour23
set-option -g status-interval 1
set-option -g status-left "#S:#P:#W[#I]"
set-option -g status-left-length 20
set-option -g status-right "#(date '+%H:%M:%S %a %d %b')"
set-option -g mode-keys vi
Fairly frequently I can see X dissapearing for a split second and the tty where tmux is flashing instead.
Last edited by hauzer (2011-08-07 13:26:43)
Vanity of vanities, saith the Preacher, vanity of vanities; all is vanity.
What profit hath a man of all his labour which he taketh under the sun?
All the rivers run into the sea; yet the sea is not full; unto the place from whence the rivers come, thither they return again.
For in much wisdom is much grief: and he that increaseth knowledge increaseth sorrow.
Offline
Okay.. It seems tmux is not reading some of my configuration commands.
I have a configuration:
~$ cat .tmux.conf
set-option -g default-shell /bin/bash
set-option -g history-limit 10000
set-option -g detach-on-destroy off
set-option -g message-bg colour231
set-option -g status-bg colour23
set-option -g status-interval 1
set-option -g status-left "#S:#P:#W[#I]"
set-option -g status-left-length 20
set-option -g status-right "#(date '+%H:%M:%S %a %d %b')"
set-option -g mode-keys vi
Which is sourced by another configuration:
~$ cat .tmux-urxvt.conf
source-file ~/.tmux.conf
set-option destroy-unattached on
The set-option command apparently doesn't set the provided option for some reason. When executing show-options there are none to be shown. However, I can set it manually once I enter tmux and it works as expected.
Vanity of vanities, saith the Preacher, vanity of vanities; all is vanity.
What profit hath a man of all his labour which he taketh under the sun?
All the rivers run into the sea; yet the sea is not full; unto the place from whence the rivers come, thither they return again.
For in much wisdom is much grief: and he that increaseth knowledge increaseth sorrow.
Offline
If you have a specific session that you want to set up, perhaps it would be better to write a shell script that instantiates a named session and sources all the config files you want, before running tmux set-option destroy-unattached on to set that session option.
Offline
I've been trying to change the window alerts but have hit a snag. Here's the relevant section of my .tmux.conf:
# color for windows with flags (activity, etc)
setw -g window-status-alert-attr none
setw -g window-status-alert-fg default
setw -g window-status-alert-bg red
This works, but it's not what I want to do. I would rather have the foreground of an alerted window be red, and the background be "default". I've tried tons of different colors for the window-status-alert-fg option, but they all show up as white. I can put any color I like into window-status-alert-bg and it works just fine, but window-status-alert-fg isn't working at all.
A couple other notes:
1) I have 256-color support set up in tmux (via screen-256color as my $TERM environment variable).
2) Problem exists both in urxvt and xterm.
Just wanted to see if others were experiencing the same problem before I went ahead and filed a bug report.
Full .tmux.conf here:
# start zsh by default for new windows
set -g default-command 'zsh'
# set default terminal
set -g default-terminal "screen-256color"
# vi keybindings, for the love of Crom
setw -g mode-keys vi
set -g status-keys vi
# enable utf-8
setw -g utf8 on
# reload statusbar every 5 seconds
set -g status-interval 5
# statusbar has white on black/transparent background
set -g status-bg default
set -g status-fg white
# black text on gray background when in copy mode. same colors for message bar.
setw -g mode-bg colour245
setw -g mode-fg black
set -g message-bg colour245
set -g message-fg black
# don't limit status-left to the 10-char default
set -g status-left-length 100
# hostname in bright red, 24-hr time in blue, date in green
set -g status-left '#[fg=red,bright]#H #[fg=blue,nobright]%k:%M #[fg=green]%d-%b'
# session name in bright red, load avg in bright green
set -g status-right '#[fg=red,bright]#S#[fg=white] | #[fg=green]#(cut -d " " -f 1-4 /proc/loadavg)'
# active pane's border in blue, other pane borders in white
set -g pane-active-border-fg blue
set -g pane-border-fg white
# set scrollback to 5000 lines
set -g history-limit 5000
# window name format
setw -g window-status-format '#[fg=white,bright]#I)#W#F'
# selected window name format
setw -g window-status-current-format '#[bg=blue]#[fg=white,bright]#I)#W#F'
# color for windows with flags (activity, etc)
setw -g window-status-alert-attr none
setw -g window-status-alert-fg default
setw -g window-status-alert-bg red
# start window numbering at 1 instead of 0
set -g base-index 1
# change command key from C-b to C-o
set -g prefix C-o
# send prefix to remote host
bind C-b send-prefix
# toggle automatic rename
bind a setw automatic-rename
# window creation/navigation/etc.
bind C-c new-window
bind C-o last-window
bind o last-window
bind C-p previous-window
bind C-n next-window
bind C-d detach
# don't switch layouts with Space/Ctrl-Space
unbind C-Space
unbind Space
# swap windows (companion to the "." default keybinding)
bind > command-prompt "swap-window -t '%%'"
# turn on activity monitoring in current window
bind M setw monitor-activity
# kill current pane (and unbind default keybinding for this action)
bind k confirm-before kill-pane
unbind x
# list sessions
bind l list-sessions
# change keybindings for window splitting
bind | split-window -h
bind - split-window
# make "C-Space" work for next-layout as well as "Space"
bind C-Space next-layout
# copy buffer to clipboard
bind C-y saveb /tmp/tmux-buffer \; run-shell "cat /tmp/tmux-buffer | xclip -selection clipboard; rm /tmp/tmux-buffer"
bind y saveb /tmp/tmux-buffer \; run-shell "cat /tmp/tmux-buffer | xclip -selection clipboard; rm /tmp/tmux-buffer"
Offline
This works for me (using the same setup: urxvt(c) and screen-256):
setw -g window-status-alert-attr default
setw -g window-status-alert-fg red
setw -g window-status-alert-bg default
Offline
That wasn't working for me, so I commented a bunch of stuff out of my .tmux.conf and started adding them back in one by one. I narrowed it down to the the window-status-format setting.
setw -g window-status-format '#[fg=white,bright]#I:#P)#W#F'
It turns out that setting any color attribute here causes the problem. I even removed the bright attribute, changed the color, and the result was the same.
Offline
Something got screwed up lately. Ncurses programs aren't working correctly (ranger, cmus), giving output similar to $TERM not set correctly.
Anyone experienced that as well. or is it just me?
Thinkpad T61p : T7700 | 4GB RAM | nVidia FX 570M | Intel 4965
Arch64 @ Openbox
Offline
vi3dr0: https://bugs.archlinux.org/task/26525
Fixed in testing.
Offline
That was quick, thank you
Thinkpad T61p : T7700 | 4GB RAM | nVidia FX 570M | Intel 4965
Arch64 @ Openbox
Offline
Just wanted to share a little tip about if wanting to enable automatic tiling in tmux in addition to the default "manual" one(or manual with presets to use after the fact), then here's two keybinds which adds tile + bstack layout(or main-vertical and main-horizontal as the propper tmux terminology rather is)...
bind v splitw\; selectl main-vertical
bind h splitw\; selectl main-horizontal
Offline