From: Simon Ruderich Date: Fri, 12 Oct 2012 14:41:21 +0000 (+0200) Subject: tmux.conf: Use line continuation. X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=ab9717d6cf1d9b0d1a5a3e2c932f39e8dd561a7f;p=config%2Fdotfiles.git tmux.conf: Use line continuation. Also add new script remove-continuation.pl which performs this change. Older Tmux versions don't support line continuation. Adapt setup.sh to generate tmux.conf from tmux.conf.in. --- diff --git a/.gitignore b/.gitignore index 1cec4e7..7d37188 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Ignore generated files. /htoprc /screenrc +/tmux.conf # Ignore temporary zsh files. /zsh/cache /zsh/history* diff --git a/bin/remove-continuation.pl b/bin/remove-continuation.pl new file mode 100755 index 0000000..8658df8 --- /dev/null +++ b/bin/remove-continuation.pl @@ -0,0 +1,42 @@ +#!/usr/bin/perl + +# Remove continuation lines from stdin/file. Leading whitespace on the next +# line is removed. + +# Copyright (C) 2012 Simon Ruderich +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +use strict; +use warnings; + + +my $continuation = 0; +while (my $line = <>) { + # Remove leading whitespace if the last line was a line continuation. + if ($continuation) { + $line =~ s/^\s+//; + } + + if ($line =~ /^(.+?)\\$/) { + print $1; + $continuation = 1; + } else { + print $line; + $continuation = 0; + } +} +# Handle line continuation on the last line. +print "\n" if $continuation; diff --git a/setup.sh b/setup.sh index 5e5acc6..8873bf6 100755 --- a/setup.sh +++ b/setup.sh @@ -93,6 +93,7 @@ fi link inputrc ~/.inputrc link screenrc ~/.screenrc if installed tmux; then + generate perl tmux.conf ./bin/remove-continuation.pl link tmux.conf ~/.tmux.conf fi if installed htop; then diff --git a/tmux.conf b/tmux.conf.in similarity index 93% rename from tmux.conf rename to tmux.conf.in index 09c6ed3..f1fe4e5 100644 --- a/tmux.conf +++ b/tmux.conf.in @@ -50,7 +50,8 @@ set-option -g status-bg colour12 # Nothing left of window list. set-option -g status-left "" # Current load average and hostname on the right. -set-option -g status-right "#(uptime | sed 's/^.*load averages*: //; s/,//g') #H" +set-option -g status-right "#(uptime | sed 's/^.*load averages*: //; s/,//g') \ + #H" # Format for windows in the window list in the status line. #I window index, # #W window number, #F window flags. @@ -92,6 +93,8 @@ bind-key C-t display-message # Run urlview on the current screen content. Very useful to follow links. # Thanks to Arch wiki (https://wiki.archlinux.org/index.php/Tmux) for the # basic idea. -bind-key C-b capture-pane \; save-buffer ~/.tmp/tmux-urlview \; new-window "$SHELL -c 'urlview < ~/.tmp/tmux-urlview'" +bind-key C-b capture-pane \; \ + save-buffer ~/.tmp/tmux-urlview \; \ + new-window "$SHELL -c 'urlview < ~/.tmp/tmux-urlview'" # vim: ft=tmux