From 488787b305889a7888555a240b99dcb1f04f7fff Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Mon, 7 Jan 2013 19:37:10 +0900 Subject: [PATCH] add tmux.conf.pl use this instead of tmux.conf --- bashrc | 2 ++ profile | 5 +++ tmux.conf.pl | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100755 tmux.conf.pl diff --git a/bashrc b/bashrc index 7ce6011..809a4c4 100755 --- a/bashrc +++ b/bashrc @@ -803,3 +803,5 @@ invader(){ EOF } #/etc/lsb-release + +echo .dotfiles/bashrc processed. diff --git a/profile b/profile index b194e5c..da477bf 100755 --- a/profile +++ b/profile @@ -2,6 +2,9 @@ # ~/.dotfiles/profile +test -n "$DOTFILES_PROFILE" && return +export DOTFILES_PROFILE=t + # export PS1="\$ " export LC_TIME=C export TERMCAP="${TERMCAP}:vb=" @@ -42,3 +45,5 @@ fi export TMP="${TMP}${USER}-tmp" export TEMP="$TMP" mkdir -p "$TMP" + +echo .dotfiles/profile processed. diff --git a/tmux.conf.pl b/tmux.conf.pl new file mode 100755 index 0000000..5770338 --- /dev/null +++ b/tmux.conf.pl @@ -0,0 +1,88 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +my $tmux_command = "tmux"; +my @tmux_set_command = ("set", "-g"); +my @tmux_setw_command = ("setw", "-g"); + +my %color_prefs = ( + "arch-aspireone" => "blue,white", + "darwin-mba.local" => "yellow,black", + "newkiwi" => "magenta,white" + ); +my $color_def = "green,white"; + +sub tmux { + my @command = ($tmux_command, ); + push(@command, @_); + # print "@command, \n"; + system(@command) == 0 + or die "system @command failed: $?"; +} + +sub set { + my @command = @tmux_set_command; + push(@command, @_); + tmux(@command); +} + +sub setw { + my @command = @tmux_setw_command; + push(@command, @_); + tmux(@command); +} + +sub set_key { + tmux("unbind", "C-b"); + set("prefix", "C-z"); + tmux("bind-key", "C-z", "send-prefix"); + tmux("bind-key", "c", "command-prompt", "new-window '%%'"); +} + +sub set_prefs { + setw("mode-keys", "vi"); + set("default-command", "/bin/bash"); + set("default-path", $ENV{"HOME"}); + set("set-titles", "on"); + set("display-panes-time", "5000"); +} + +sub set_status_line { + my $user = $ENV{"USER"}; + my $hostname = $ENV{"HOSTNAME"}; + my $tmux_v = `tmux -V`; + $tmux_v =~ s/\n//; + set("status-right", "${user}\@${hostname} | ${tmux_v} "); +} + +sub set_colors { + my $hostname = $ENV{"HOSTNAME"}; + my $color = $color_prefs{$hostname}; + if (! $color) { + $color = $color_def; + } + my ($bg, $fg) = split(/,/, $color); + set("status-bg", $bg); + set("status-fg", $fg); + set("mode-bg", $bg); + set("mode-fg", $fg); + set("pane-active-border-fg", $bg); + + set("message-bg", "white"); + set("message-fg", "black"); + + setw("window-status-current-bg", "white"); + setw("window-status-current-fg", "black"); + setw("window-status-current-attr", "bold"); +} + +sub main { + set_key(); + set_prefs(); + set_status_line(); + set_colors(); +} + +main();