581 lines
17 KiB
HTML
581 lines
17 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en-us">
|
|
<head>
|
|
|
|
<meta charset="utf-8" />
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
|
|
|
|
|
|
<meta name="twitter:card" content="summary"/>
|
|
|
|
|
|
|
|
|
|
<meta name="twitter:title" content="My tmux configuration"/>
|
|
<meta name="twitter:description" content=""/>
|
|
<meta name="twitter:site" content="@"/>
|
|
|
|
|
|
|
|
<meta property="og:title" content="My tmux configuration · Sysadmining. All day. Every day." />
|
|
<meta property="og:site_name" content="Sysadmining. All day. Every day." />
|
|
<meta property="og:url" content="https://www.captainark.net/2016/02/02/my-tmux-configuration/" />
|
|
|
|
|
|
|
|
<meta property="og:image" content="/images/cover.jpg"/>
|
|
|
|
|
|
|
|
|
|
<meta property="og:description" content="" />
|
|
<meta property="og:type" content="article" />
|
|
<meta property="article:published_time" content="2016-02-02T00:00:00+01:00" />
|
|
|
|
|
|
|
|
|
|
<title>My tmux configuration · Sysadmining. All day. Every day.</title>
|
|
|
|
|
|
<meta name="description" content="tmux is a terminal mutiplexer. It lets you have multiples shells running in a single terminal emulator window and it keeps those shells running in the backgroun" />
|
|
|
|
|
|
<meta name="HandheldFriendly" content="True" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
|
|
<link rel="apple-touch-icon" sizes="180x180" href="https://www.captainark.net/apple-touch-icon.png">
|
|
<link rel="icon" type="image/png" sizes="32x32" href="https://www.captainark.net/favicon-32x32.png">
|
|
<link rel="icon" type="image/png" sizes="16x16" href="https://www.captainark.net/favicon-16x16.png">
|
|
<link rel="manifest" href="https://www.captainark.net/site.webmanifest">
|
|
<link rel="mask-icon" href="https://www.captainark.net/safari-pinned-tab.svg" color="#5bbad5">
|
|
<meta name="msapplication-TileColor" content="#9f00a7">
|
|
<meta name="theme-color" content="#ffffff">
|
|
|
|
<link rel="stylesheet" type="text/css" href="https://www.captainark.net/css/screen.css" />
|
|
<link rel="stylesheet" type="text/css" href="https://www.captainark.net/css/nav.css" />
|
|
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Merriweather:300,700,700italic,300italic|Open+Sans:700,400|Inconsolata:700,400" />
|
|
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/styles/solarized-light.min.css" integrity="sha384-bFKDPkG3geCujYJIbPornilfOgmYQoPS45Oh/8daqqo1SUwNY06OeHorpgnNvx82" crossorigin="anonymous">
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/highlight.min.js" integrity="sha384-BlPof9RtjBqeJFskKv3sK3dh4Wk70iKlpIe92FeVN+6qxaGUOUu+mZNpALZ+K7ya" crossorigin="anonymous"></script>
|
|
|
|
<script type="text/javascript" src="https://www.captainark.net/js/hjsload.js"></script>
|
|
|
|
|
|
|
|
|
|
<link href="https://www.captainark.net/index.xml" rel="alternate" type="application/rss+xml" title="Sysadmining. All day. Every day." />
|
|
|
|
|
|
|
|
<meta name="generator" content="Hugo 0.54.0" />
|
|
|
|
<link rel="canonical" href="https://www.captainark.net/2016/02/02/my-tmux-configuration/" />
|
|
|
|
|
|
|
|
|
|
<script type="application/ld+json">
|
|
{
|
|
"@context": "https://schema.org",
|
|
"@type": "Article",
|
|
"publisher": {
|
|
"@type": "Organization",
|
|
"name": ,
|
|
"logo": https://www.captainark.net/images/logo.png
|
|
},
|
|
"author": {
|
|
"@type": "Person",
|
|
"name": ,
|
|
|
|
"image": {
|
|
"@type": "ImageObject",
|
|
"url": https://www.captainark.net/images/author.jpg,
|
|
"width": 250,
|
|
"height": 250
|
|
},
|
|
|
|
"url": https://www.captainark.net,
|
|
"sameAs": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
],
|
|
"description": Geek | Gamer | TV Shows Aficionado
|
|
|
|
},
|
|
"headline": My tmux configuration,
|
|
"name": My tmux configuration,
|
|
"wordCount": 708,
|
|
"timeRequired": "PT4M",
|
|
"inLanguage": {
|
|
"@type": "Language",
|
|
"alternateName": en
|
|
},
|
|
"url": https://www.captainark.net/2016/02/02/my-tmux-configuration/,
|
|
"datePublished": 2016-02-02T00:00Z,
|
|
"dateModified": 2016-02-02T00:00Z,
|
|
|
|
|
|
"description": ,
|
|
"mainEntityOfPage": {
|
|
"@type": "WebPage",
|
|
"@id": https://www.captainark.net/2016/02/02/my-tmux-configuration/
|
|
}
|
|
}
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript" src="https://www.captainark.net/js/stats.js"></script>
|
|
|
|
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/fork-awesome@1.1.7/css/fork-awesome.min.css" integrity="sha256-gsmEoJAws/Kd3CjuOQzLie5Q3yshhvmo7YNtBG7aaEY=" crossorigin="anonymous">
|
|
|
|
|
|
</head>
|
|
<body class="nav-closed">
|
|
|
|
<div class="nav">
|
|
<h3 class="nav-title">Menu</h3>
|
|
<a href="#" class="nav-close">
|
|
<span class="hidden">Close</span>
|
|
</a>
|
|
<ul>
|
|
|
|
|
|
|
|
<h3>This site</h3>
|
|
<li class="nav-opened" role="presentation">
|
|
<a href="https://www.captainark.net/">Home</a>
|
|
</li>
|
|
|
|
|
|
<li class="nav-opened" role="presentation">
|
|
<a href="https://www.captainark.net/about">About</a>
|
|
</li>
|
|
|
|
|
|
<li class="nav-opened" role="presentation">
|
|
<a href="https://www.captainark.net/resume">Resume</a>
|
|
</li>
|
|
|
|
<h3>Other services</h3>
|
|
<li class="nav-opened" role="presentation">
|
|
<a href="https://chat.captainark.net">Rocket.Chat</a>
|
|
</li>
|
|
|
|
|
|
<li class="nav-opened" role="presentation">
|
|
<a href="https://notes.captainark.net">CodiMD</a>
|
|
</li>
|
|
|
|
|
|
<li class="nav-opened" role="presentation">
|
|
<a href="https://git.captainark.net">Gitea</a>
|
|
</li>
|
|
|
|
|
|
<li class="nav-opened" role="presentation">
|
|
<a href="https://paste.captainark.net">Privatebin</a>
|
|
</li>
|
|
|
|
|
|
<li class="nav-opened" role="presentation">
|
|
<a href="https://pics.captainark.net">Pics</a>
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
<a class="subscribe-button icon-feed" href="https://www.captainark.net/index.xml">Subscribe</a>
|
|
|
|
</div>
|
|
<span class="nav-cover"></span>
|
|
|
|
|
|
<div class="site-wrapper">
|
|
|
|
|
|
|
|
<header class="main-header post-head no-cover">
|
|
<nav class="main-nav clearfix">
|
|
|
|
|
|
|
|
<a class="blog-logo" href="https://www.captainark.net/"><img src="https://www.captainark.net/images/logo.png" alt="Home" /></a>
|
|
|
|
|
|
<a class="menu-button" href="#"><span class="burger">☰</span><span class="word">Menu</span></a>
|
|
|
|
</nav>
|
|
</header>
|
|
|
|
|
|
|
|
<main class="content" role="main">
|
|
|
|
|
|
|
|
|
|
<article class="post post">
|
|
|
|
<header class="post-header">
|
|
<h1 class="post-title">My tmux configuration</h1>
|
|
<small></small>
|
|
|
|
<section class="post-meta">
|
|
|
|
<time class="post-date" datetime="2016-02-02T00:00:00+01:00">
|
|
02 February 2016
|
|
</time>
|
|
|
|
|
|
</section>
|
|
</header>
|
|
|
|
<section class="post-content">
|
|
|
|
|
|
<p><a href="https://tmux.github.io/">tmux</a> is a terminal mutiplexer. It lets you have multiples shells running in a single terminal emulator window and it keeps those shells running in the background should you need to close your terminal emulator.</p>
|
|
|
|
<p>I’ve played around with the configuration quite a bit to find settings that suit my needs. Here’s what it ended up looking like :</p>
|
|
|
|
<p><img src="https://www.captainark.net/images/tmux.png" alt="tmux_fullsize" /></p>
|
|
|
|
<p>This screenshot was done on Mac OS X, using the Terminal app and this <a href="https://github.com/tomislav/osx-terminal.app-colors-solarized">Solarized theme</a>.</p>
|
|
|
|
<p>I figured I’d share my tmux configuration here !</p>
|
|
|
|
<h2 id="installing-tmux">Installing tmux</h2>
|
|
|
|
<p>tmux is available on Debian. I suggest using the <a href="https://packages.debian.org/jessie-backports/tmux">jessie backports</a> version :</p>
|
|
|
|
<p><code>apt -t jessie-backports install tmux</code></p>
|
|
|
|
<p>tmux is also available on Mac OS X using <a href="http://brew.sh/">brew</a> :</p>
|
|
|
|
<p><code>brew install tmux</code></p>
|
|
|
|
<h2 id="tmux-conf">tmux.conf</h2>
|
|
|
|
<p>I used screen before tmux, so I configured the prefix key on C-a instead of C-b. tmux has the advantage of being <em>much</em> simpler to configure than screen.</p>
|
|
|
|
<p>If you want to use this configuration, simply copy the following in ~/.tmux.conf. This file is read by default when tmux starts.</p>
|
|
|
|
<p>If you simply want to try it out, copy it in a file somewhere else and have tmux load with the -f parameter (<code>tmux -f ~/tmux-test.conf</code>).</p>
|
|
|
|
<pre><code># use utf8
|
|
set -g utf8
|
|
set-option -g status-utf8 on
|
|
set-window-option -g utf8 on
|
|
|
|
# do not wait on esc key
|
|
set-option -g escape-time 0
|
|
|
|
# completely disable automatic rename
|
|
set-window-option -g automatic-rename off
|
|
|
|
# basic settings
|
|
set -g default-terminal "screen-256color"
|
|
set -g aggressive-resize off
|
|
set-window-option -g xterm-keys on
|
|
#set-window-option -g mode-mouse off
|
|
|
|
# command history
|
|
set -g history-limit 10000
|
|
|
|
# messages
|
|
set -g message-bg default
|
|
set -g message-fg red
|
|
|
|
# no visual activity
|
|
set -g visual-activity off
|
|
set -g visual-bell off
|
|
|
|
# status bar
|
|
set-option -g status-justify centre
|
|
set-option -g status-bg default
|
|
set-option -g status-fg blue
|
|
set-option -g status-interval 5
|
|
set-option -g status-left-length 30
|
|
set-option -g status-left '#[fg=red][ #[fg=white]#H #[fg=red]]#[default]'
|
|
set-option -g status-right '#[fg=red][ #[fg=white]%R %d/%m #[fg=red]]#[default]'
|
|
|
|
# modes
|
|
set-option -g mode-bg default
|
|
set-option -g mode-fg blue
|
|
|
|
# inactive window format
|
|
set-window-option -g window-status-format '#I:#W#F'
|
|
set-window-option -g monitor-activity on
|
|
#set-window-option -g monitor-content on # not available in tmux 2.0
|
|
|
|
# activity in a window
|
|
set-window-option -g window-status-activity-attr dim
|
|
set-window-option -g window-status-activity-bg default
|
|
set-window-option -g window-status-activity-fg yellow
|
|
|
|
# content in a window # not available in tmux 2.0
|
|
#set-window-option -g window-status-content-attr dim
|
|
#set-window-option -g window-status-content-bg default
|
|
#set-window-option -g window-status-content-fg red
|
|
|
|
# active window format
|
|
set-window-option -g window-status-current-fg white
|
|
set-window-option -g window-status-current-bg default
|
|
set-window-option -g window-status-current-format '#[fg=red](#[default]#I:#W#F#[fg=red])#[default]'
|
|
|
|
# reload tmux configuration
|
|
unbind r
|
|
bind r source-file ~/.tmux.conf \; display "Configuration reloaded!"
|
|
|
|
# Screen-like keybinds
|
|
unbind C-b
|
|
set -g prefix ^A
|
|
set -g prefix2 ^Q
|
|
bind a send-prefix
|
|
bind q send-prefix
|
|
|
|
unbind c
|
|
bind c new-window
|
|
unbind ^C
|
|
bind ^C new-window
|
|
|
|
unbind n
|
|
bind n next-window
|
|
unbind ^N
|
|
bind ^N next-window
|
|
|
|
unbind A
|
|
bind A command-prompt "rename-window %%"
|
|
|
|
unbind p
|
|
bind p previous-window
|
|
unbind ^P
|
|
bind ^P previous-window
|
|
|
|
unbind a
|
|
bind a last-window
|
|
unbind ^A
|
|
bind ^A last-window
|
|
|
|
unbind [
|
|
bind Escape copy-mode
|
|
|
|
unbind w
|
|
bind w list-windows
|
|
|
|
unbind k
|
|
bind k confirm-before "kill-window"
|
|
|
|
unbind l
|
|
bind l refresh-client
|
|
|
|
unbind '"'
|
|
bind '"' choose-window
|
|
</code></pre>
|
|
|
|
<h2 id="aliases">Aliases</h2>
|
|
|
|
<p>I also use two functions with tmux (in ~/.bash_aliases).</p>
|
|
|
|
<p>The first one creates a new “mytmux” tmux session if one doesn’t exist yet, opens 10 shells and selects the first one.</p>
|
|
|
|
<pre><code class="language-bash">mytmux() {
|
|
tmux has-session -t mytmux
|
|
if [ $? != 0 ]; then
|
|
tmux new-session -s mytmux -n $(hostname) -d
|
|
tmux new-window -t mytmux:1 -n $(hostname)
|
|
tmux new-window -t mytmux:2 -n $(hostname)
|
|
tmux new-window -t mytmux:3 -n $(hostname)
|
|
tmux new-window -t mytmux:4 -n $(hostname)
|
|
tmux new-window -t mytmux:5 -n $(hostname)
|
|
tmux new-window -t mytmux:6 -n $(hostname)
|
|
tmux new-window -t mytmux:7 -n $(hostname)
|
|
tmux new-window -t mytmux:8 -n $(hostname)
|
|
tmux new-window -t mytmux:9 -n $(hostname)
|
|
tmux select-window -t mytmux:0
|
|
fi
|
|
tmux attach -t mytmux
|
|
}
|
|
</code></pre>
|
|
|
|
<p>The second one changes the tmux window name whenever I ssh to a remote host, and switches the window name back to the name of my computer when I logout from the host.</p>
|
|
|
|
<pre><code class="language-bash">if [ -n "$TMUX" ]; then
|
|
ssh() {
|
|
if [ $# -le 2 ]; then
|
|
tmux rename-window "${@: -1}"
|
|
command ssh "$@"
|
|
tmux rename-window "$(hostname)"
|
|
else
|
|
command ssh "$@"
|
|
fi
|
|
}
|
|
fi
|
|
</code></pre>
|
|
|
|
<h2 id="conclusion">Conclusion</h2>
|
|
|
|
<p>That’s all ! As always, please do leave a comment if you’ve found something useful in this article !</p>
|
|
|
|
</section>
|
|
|
|
|
|
<footer class="post-footer">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<figure class="author-image">
|
|
<a class="img" href="https://www.captainark.net/" style="background-image: url(/images/author.jpg)"><span class="hidden">Antoine Joubert's Picture</span></a>
|
|
</figure>
|
|
|
|
|
|
<section class="author">
|
|
<h4><a href="https://www.captainark.net/">Antoine Joubert</a></h4>
|
|
|
|
<p>Geek | Gamer | TV Shows Aficionado</p>
|
|
|
|
<div class="author-meta">
|
|
<span class="author-location icon-location">Angers, France</span>
|
|
<span class="author-link icon-link"><a href="https://www.captainark.net">https://www.captainark.net</a></span>
|
|
</div>
|
|
</section>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- isso -->
|
|
<script data-isso="https://www.captainark.net/comments/" src="https://www.captainark.net/comments/js/embed.min.js"></script>
|
|
<noscript>Please enable JavaScript to view comments</noscript>
|
|
<section id="isso-thread"></section>
|
|
<!-- end isso -->
|
|
|
|
|
|
|
|
|
|
</footer>
|
|
</article>
|
|
|
|
</main>
|
|
|
|
|
|
<aside class="read-next">
|
|
|
|
<a class="read-next-story" style="no-cover" href="https://www.captainark.net/2016/03/13/mysql-backup-script/">
|
|
<section class="post">
|
|
<h2>MySQL backup script</h2>
|
|
|
|
</section>
|
|
</a>
|
|
|
|
|
|
<a class="read-next-story prev" style="no-cover" href="https://www.captainark.net/2016/01/31/debian-updates-with-ansible/">
|
|
<section class="post">
|
|
<h2>Debian updates with Ansible</h2>
|
|
</section>
|
|
</a>
|
|
|
|
</aside>
|
|
|
|
|
|
|
|
|
|
<center>
|
|
<a class="fa-icons" href="mailto:contact@captainark.net">
|
|
<span class="fa-stack fa-lg">
|
|
<i class="fa fa-circle fa-stack-2x"></i>
|
|
<i class="fa fa-envelope fa-stack-1x fa-inverse"></i>
|
|
</span>
|
|
</a>
|
|
<a class="fa-icons" href="https://twitter.com/captainark">
|
|
<span class="fa-stack fa-lg">
|
|
<i class="fa fa-circle fa-stack-2x"></i>
|
|
<i class="fa fa-twitter fa-stack-1x fa-inverse"></i>
|
|
</span>
|
|
</a>
|
|
<a class="fa-icons" href="https://social.captainark.net/users/captainark">
|
|
<span class="fa-stack fa-lg">
|
|
<i class="fa fa-circle fa-stack-2x"></i>
|
|
<i class="fa fa-mastodon-alt fa-stack-1x fa-inverse"></i>
|
|
</span>
|
|
</a>
|
|
<a class="fa-icons" href="https://github.com/captainark">
|
|
<span class="fa-stack fa-lg">
|
|
<i class="fa fa-circle fa-stack-2x"></i>
|
|
<i class="fa fa-github fa-stack-1x fa-inverse"></i>
|
|
</span>
|
|
</a>
|
|
<a class="fa-icons" href="https://www.last.fm/user/captainark">
|
|
<span class="fa-stack fa-lg">
|
|
<i class="fa fa-circle fa-stack-2x"></i>
|
|
<i class="fa fa-lastfm fa-stack-1x fa-inverse"></i>
|
|
</span>
|
|
</a>
|
|
<a class="fa-icons" href="https://steamcommunity.com/id/captainark">
|
|
<span class="fa-stack fa-lg">
|
|
<i class="fa fa-circle fa-stack-2x"></i>
|
|
<i class="fa fa-steam fa-stack-1x fa-inverse"></i>
|
|
</span>
|
|
</a>
|
|
<a class="fa-icons" href="https://www.twitch.tv/captainark">
|
|
<span class="fa-stack fa-lg">
|
|
<i class="fa fa-circle fa-stack-2x"></i>
|
|
<i class="fa fa-twitch fa-stack-1x fa-inverse"></i>
|
|
</span>
|
|
</a>
|
|
</center>
|
|
|
|
|
|
<footer class="site-footer clearfix">
|
|
<section class="copyright"><a href="">Sysadmining. All day. Every day.</a> © 2015 - 2019</section>
|
|
|
|
<section class="poweredby">Proudly generated by <a class="icon-hugo" href="http://gohugo.io">HUGO</a>, with <a class="icon-theme" href="https://github.com/vjeantet/hugo-theme-casper">Casper</a> theme</section>
|
|
|
|
</footer>
|
|
</div>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js" integrity="sha384-CgeP3wqr9h5YanePjYLENwCTSSEz42NJkbFpAFgHWQz7u3Zk8D00752ScNpXqGjS" crossorigin="anonymous"></script>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/fitvids/1.1.0/jquery.fitvids.min.js" integrity="sha384-2/VQUb0aZHixKnNLh7pD38DZk+acGpEw5LeHieWVDPR0h/H326kp/1qnRPDYmFXM" crossorigin="anonymous"></script>
|
|
<script type="text/javascript" src="https://www.captainark.net/js/index.js"></script>
|
|
</body>
|
|
</html>
|
|
|