From aa26a7c929312276abc254ac451454a0984fc372 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Mon, 7 Jan 2013 10:35:07 +0900 Subject: [PATCH 1/3] add alias locate for mac --- bashrc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bashrc b/bashrc index 2428e9a..cb2b693 100755 --- a/bashrc +++ b/bashrc @@ -168,6 +168,8 @@ null type aunpack && alias aunp=aunpack null type lv && alias lv="lv|less" isdarwin && alias updatedb="LC_ALL=C updatedb" +# do not use locate installed by macports +isdarwin && test -x /usr/bin/locate && alias locate="/usr/bin/locate" # pad alias pad=notepad From 0aa7a87e4a632cd1d7293460e8bf0bef6a689a30 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Mon, 7 Jan 2013 17:35:28 +0900 Subject: [PATCH 2/3] update PS1 --- bashrc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bashrc b/bashrc index cb2b693..7ce6011 100755 --- a/bashrc +++ b/bashrc @@ -671,7 +671,7 @@ __my_ps1_script(){ } __my_ps1_scale(){ local last=$? - echo "[LC:${LINES}x${COLUMNS}]" + printf "${LINES}x${COLUMNS}" return $last } __my_ps1_tmux(){ @@ -736,9 +736,17 @@ then __my_c5="\[\e[30;47m\]" # color for SCR __my_cdef="\[\e[0m\]" fi + +export _LAST_STATUS=$? +__my_export_last_status(){ + export _LAST_STATUS=$? + echo $_LAST_STATUS + return $_LAST_STATUS +} + _PS1="\ -${__my_c4}:: ${__my_cdef}[${__my_c2}\u@\H${__my_cdef}:${__my_c1}\w/${__my_cdef}]\$(__my_ps1_scale)\$(__my_ps1_git)\$(__my_ps1_bttry)\$(__my_ps1_ipaddr)\$(__my_ps1_moc)\n\ -${__my_c4}:: ${__my_cdef}l${SHLVL}n\#j\js\$? \D{%T} $(__my_ps1_script)\$ " +${__my_c4}:: ${__my_cdef}[${__my_c2}\u@\H${__my_cdef}:${__my_c1}\w/${__my_cdef}]\$(__my_ps1_git)\$(__my_ps1_bttry)\$(__my_ps1_ipaddr)\$(__my_ps1_moc)\n\ +${__my_c4}:: ${__my_cdef}l${SHLVL}n\#j\js\$? $(__my_ps1_scale) \D{%T} $(__my_ps1_script)\$ " PS1=$_PS1 __my_set_title(){ 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 3/3] 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();