From 1ddba92571896310e978d9fc594a36683c4da89e Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Tue, 26 Nov 2013 00:27:59 +0900 Subject: [PATCH] remove tmux.conf.pl, colors and status bar are made by setup.sh --- setup.sh | 40 ++++++++++++++++++++ tmux.conf | 26 +++++++++++++ tmux.conf.pl | 101 --------------------------------------------------- 3 files changed, 66 insertions(+), 101 deletions(-) create mode 100644 tmux.conf delete mode 100755 tmux.conf.pl diff --git a/setup.sh b/setup.sh index 848ad9d..d82dd0b 100755 --- a/setup.sh +++ b/setup.sh @@ -53,6 +53,45 @@ __homevar="$__homevar" __EOC__ } +############################# +# gen_tmux_conf_local + +gen_tmux_conf_local(){ + tmux_conf_local="$HOME/.tmux.conf.local" + + case "`hostname`" in + arch-aspireone) + tmux_bg_color=blue + tmux_fg_color=white + ;; + darwin-mba.local) + tmux_bg_color=cyan + tmux_fg_color=black + ;; + newkiwi) + tmux_bg_color=magenta + tmux_fg_color=white + ;; + *) + tmux_bg_color=green + tmux_fg_color=black + ;; + esac + + cat <<__EOC__ >"$tmux_conf_local" +# $tmux_conf_local +# Automatically generated from $0 + +set -g status-right "${USER}@$(hostname) | $(tmux -V) " + +set -g status-bg $tmux_bg_color +set -g status-fg $tmux_fg_color +set -g mode-bg $tmux_bg_color +set -g mode-fg $tmux_fg_color +set -g pane-active-border-fg $tmux_bg_color +__EOC__ +} + ############################## # install_scripts @@ -196,6 +235,7 @@ main(){ mkdirs install_scripts git_configs + gen_tmux_conf_local if $isdarwin then darwin_set_defaults diff --git a/tmux.conf b/tmux.conf new file mode 100644 index 0000000..efacd2b --- /dev/null +++ b/tmux.conf @@ -0,0 +1,26 @@ +# tmux.conf + +if "test -f $HOME/.tmux.conf.local" "source-file $HOME/.tmux.conf.local" \ + "display-message \"$HOME/.tmux.conf.local not found\"" + +unbind C-b +set -g prefix C-z +bind C-z send-prefix +bind c command-prompt "new-window '%%'" +bind C-r source-file ~/.tmux.conf \; display-message "Reloaded config !!" + +set -g base-index 1 +set -g pane-base-index 1 +set -g renumber-windows on +setw -g mode-keys vi +setw -g mode-mouse off +#set -g default-command /bin/bash + +#set -g default-path "$HOME" +set -g set-titles on +set -g display-panes-time 5000 + +set -g message-bg white +set -g message-fg black +setw -g window-status-current-bg white +setw -g window-status-current-fg black diff --git a/tmux.conf.pl b/tmux.conf.pl deleted file mode 100755 index 6a82918..0000000 --- a/tmux.conf.pl +++ /dev/null @@ -1,101 +0,0 @@ -#!/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" => "cyan,black", - "newkiwi" => "magenta,white" - ); -my $color_def = "green,black"; - -sub tmux { - my @command = ($tmux_command, ); - push(@command, @_); - # print "@command, \n"; - system(@command) == 0 - or warn "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 { - # this does not workd because `run' do script asyncly - set("base-index", "1"); - set("pane-base-index", "1"); - set("renumber-windows", "on"); - setw("mode-keys", "vi"); - set("default-command", "/bin/bash"); - set("default-path", $ENV{"HOME"}); - set("set-titles", "on"); - set("display-panes-time", "5000"); -} - -sub get_hostname { - my $hostname = $ENV{"HOSTNAME"}; - if (! $hostname) { - $hostname = `hostname`; - chomp($hostname) - } - return $hostname; -} - -sub set_status_line { - my $user = $ENV{"USER"}; - my $hostname = get_hostname(); - my $tmux_v = `tmux -V`; - $tmux_v =~ s/\n//; - set("status-right", "${user}\@${hostname} | ${tmux_v} "); -} - -sub set_colors { - my $hostname = get_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();