6672280a6933

random stuff from the past few days
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Mon, 18 Jun 2012 11:23:24 -0400
parents be745fa0d1ab
children 176ee9c2874f
branches/tags (none)
files fish/config.fish fish/virtualenv.fish keymando/keymandorc.rb moom/com.manytricks.Moom.plist pentadactylrc weechat/perl/autoload/colorize_lines.pl

Changes

--- a/fish/config.fish	Tue Jun 12 11:56:48 2012 -0400
+++ b/fish/config.fish	Mon Jun 18 11:23:24 2012 -0400
@@ -1,10 +1,13 @@
 # Useful aliases {{{
 
+alias serve_this 'python -m SimpleHTTPServer'
 alias fab 'fab -i ~/.ssh/stevelosh'
 alias oldgcc 'set -g CC /usr/bin/gcc-4.0'
 alias tm 'tmux -u2'
 alias c 'clear'
 alias hl 'less -R'
+alias paththis 'set PATH (pwd) $PATH'
+alias clc './get-last-commit-url.py | pbcopy'
 
 alias ef 'vim ~/.config/fish/config.fish'
 
@@ -15,6 +18,7 @@
 alias pbp 'pbpaste'
 
 alias v 'vim'
+alias V 'vim .'
 
 alias vu 'vagrant up'
 alias vs 'vagrant suspend'
@@ -22,6 +26,9 @@
 alias o 'open'
 alias oo 'open .'
 
+alias wo 'workon'
+alias deact 'deactivate'
+
 # }}}
 # Environment variables {{{
 
@@ -34,6 +41,8 @@
 set PATH "/opt/subversion/bin"     $PATH
 set PATH "$HOME/lib/hg/hg"         $PATH
 
+set PATH "$HOME/Library/Haskell/bin" $PATH
+
 set PATH "/usr/local/Cellar/ruby/1.9.3-p194/bin" $PATH
 
 set PATH "/usr/local/Cellar/ruby/1.9.3-p125/bin" $PATH
@@ -66,6 +75,9 @@
 set PYTHONPATH "$HOME/lib/python/see:$PYTHONPATH"
 set PYTHONPATH "$HOME/lib/hg/hg:$PYTHONPATH"
 
+set -gx WORKON_HOME "$HOME/lib/virtualenvs"
+. ~/.config/fish/virtualenv.fish
+
 # }}}
 # Z {{{
 
@@ -84,6 +96,12 @@
 set hg_promptstring "< on $magenta<branch>$normal>< at $yellow<tags|$normal, $yellow>$normal>$green<status|modified|unknown><update>$normal<
 patches: <patches|join( → )|pre_applied($yellow)|post_applied($normal)|pre_unapplied($gray)|post_unapplied($normal)>>" 2>/dev/null
 
+function virtualenv_prompt
+    if [ -n "$VIRTUAL_ENV" ]
+        printf '(%s) ' (basename "$VIRTUAL_ENV")
+    end
+end
+
 function hg_prompt
     # hg prompt --angle-brackets $hg_promptstring 2>/dev/null
 end
@@ -126,6 +144,8 @@
 
     echo
 
+    virtualenv_prompt
+
     if test $last_status -eq 0
         set_color white -o
         printf '><((°> '
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fish/virtualenv.fish	Mon Jun 18 11:23:24 2012 -0400
@@ -0,0 +1,46 @@
+# mostly from http://coderseye.com/2010/using-virtualenv-with-fish-shell.html
+
+function workon -d "Activate virtual environment in $WORKON_HOME"
+  set tgt {$WORKON_HOME}/$argv[1]
+
+  if [ ! -d $tgt ]
+    mkdir -p "$WORKON_HOME"
+    virtualenv $tgt
+  end
+
+  if [ -d $tgt ]
+    cd $tgt
+
+    deactivate
+
+    set -gx VIRTUAL_ENV "$tgt"
+    set -gx _OLD_VIRTUAL_PATH $PATH
+    set -gx PATH "$VIRTUAL_ENV/bin" $PATH
+
+    # unset PYTHONHOME if set
+    if set -q PYTHONHOME
+       set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
+       set -e PYTHONHOME
+    end
+
+    echo "activated $tgt"
+  else
+    echo "$tgt not found"
+  end
+end
+
+complete -c workon -a "(cd $WORKON_HOME; ls -d *)"
+
+function deactivate -d "Exit virtualenv and return to normal shell environment"
+    # reset old environment variables
+    if test -n "$_OLD_VIRTUAL_PATH"
+        set -gx PATH $_OLD_VIRTUAL_PATH
+        set -e _OLD_VIRTUAL_PATH
+    end
+    if test -n "$_OLD_VIRTUAL_PYTHONHOME"
+        set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
+        set -e _OLD_VIRTUAL_PYTHONHOME
+    end
+    set -e VIRTUAL_ENV
+end
+
--- a/keymando/keymandorc.rb	Tue Jun 12 11:56:48 2012 -0400
+++ b/keymando/keymandorc.rb	Mon Jun 18 11:23:24 2012 -0400
@@ -11,16 +11,21 @@
 map "<Ctrl-Shift-J>", lambda { activate('Firefox') }
 map "<Ctrl-Shift-P>", lambda { activate('Pixelmator') }
 map "<Ctrl-Shift-H>", lambda { activate('Pixen') }
-map "<Ctrl-Shift-K>", lambda { activate('iTerm') }
 map "<Ctrl-Shift-O>", lambda { activate('Rdio') }
 map "<Ctrl-Shift-Y>", lambda { activate('Twitter') }
 
+map "<Ctrl-Shift-K>" do
+    activate('iTerm')
+    send('<Cmd-Option-2>')
+end
 map "<Ctrl-Shift-M>" do
-    activate('iDvtm')
+    activate('iTerm')
+    send('<Cmd-Option-1>')
     send('<Ctrl-f>2')
 end
 map "<Ctrl-Shift-I>" do
-    activate('iDvtm')
+    activate('iTerm')
+    send('<Cmd-Option-1>')
     send('<Ctrl-f>1')
 end
 
Binary file moom/com.manytricks.Moom.plist has changed
--- a/pentadactylrc	Tue Jun 12 11:56:48 2012 -0400
+++ b/pentadactylrc	Mon Jun 18 11:23:24 2012 -0400
@@ -43,8 +43,8 @@
 inoremap <c-g> <esc><m-a-k><esc>
 
 " Inspect element toggle
-nnoremap <c-f> <m-a-i>
-inoremap <c-f> <esc><m-a-i>
+nnoremap <c-s> <m-a-i>
+inoremap <c-s> <esc><m-a-i>
 
 " Shift is hard.
 nnoremap ; :
--- a/weechat/perl/autoload/colorize_lines.pl	Tue Jun 12 11:56:48 2012 -0400
+++ b/weechat/perl/autoload/colorize_lines.pl	Mon Jun 18 11:23:24 2012 -0400
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2010-2011 by Nils Görs <weechatter@arcor.de>
+# Copyright (c) 2010-2012 by Nils Görs <weechatter@arcor.de>
 #
 # colors the channel text with nick color and also highlight the whole line
 # colorize_nicks.py script will be supported
@@ -20,17 +20,22 @@
 # for settings see help page
 #
 # history:
-# 1.0: fixed: irc.look.nick_prefix wasn't supported
+# 1.3: fix: now using weechat::buffer_get_string() instead of regex to prevent problems with dots inside server-/channelnames (reported by surfhai)
+# 1.2: add: hook_modifier("colorize_lines") to use colorize_lines with another script.
+#    : fix: regex was too greedy and also hit tag "prefix_nick_ccc"
+# 1.1: fix:  problems with temporary server (reported by nand`)
+#    : improved: using weechat_string_has_highlight()
+# 1.0: fix: irc.look.nick_prefix wasn't supported
 # 0.9: added: option "own_nick" (idea by travkin)
 #    : new value (always) for option highlight
 #    : clean up code
-# 0.8.1: fixed: regex()
+# 0.8.1: fix: regex()
 # 0.8: added: option "avail_buffer" and "nicks" (please read help-page) (suggested by ldvx)
-#    : fixed: blacklist_channels wasn't load at start
-#    : fixed: nick_modes wasn't displayed since v0.7
+#    : fix: blacklist_channels wasn't load at start
+#    : fix: nick_modes wasn't displayed since v0.7
 #    : rewrote init() routine
 #    : thanks to stfn for hint with unescaped variables in regex.
-# 0.7: fixed: bug when irc.look.nick_suffix was set (reported and beta-testing by: hw2) (>= weechat 0.3.4)
+# 0.7: fix: bug when irc.look.nick_suffix was set (reported and beta-testing by: hw2) (>= weechat 0.3.4)
 #      blacklist_channels option supports servername
 #      clean up code
 # 0.6: code optimazations.
@@ -55,7 +60,7 @@
 
 use strict;
 my $prgname	= "colorize_lines";
-my $version	= "1.0";
+my $version	= "1.3";
 my $description	= "colors text in chat area with according nick color. Highlight messages will be fully highlighted in chat area";
 
 # default values
@@ -102,7 +107,7 @@
 sub colorize_cb {
 my ( $data, $modifier, $modifier_data, $string ) = @_;
 
-if (index($modifier_data,"irc_privmsg") == -1){							# its neither a channel nor a query buffer
+if (index($modifier_data,"irc_privmsg") == -1){                                                 # its neither a channel nor a query buffer
   return $string;
 }
 
@@ -110,11 +115,16 @@
   return $string;
 }
 
-$modifier_data =~ (m/irc;(.+?)\.(.+?)\;/);                                                      # irc;servername.channelname;
-my ($t0, $t1 , $t2) = split(/;/,$modifier_data);
-#$t1 =~ m/^(.+)\.(.+)$/;
-my $servername = $1;
-my $channel_name = $2;
+# get servername and channelname. Do not use regex to extract server- and channelname out of $modifier_data. You will FAIL!
+# some possible names: freenode.#weechat, freenode.#weechat.de, freenode.query, chat.freenode.net.#weechat, chat.freenode.net.#weechat.de
+$modifier_data =~ (m/(.*);(.*);/);
+my $plugin = $1;
+my $name = $2;
+my $buf_pointer = weechat::buffer_search($plugin,$name);
+return $string if ($buf_pointer eq "");
+my $servername = weechat::buffer_get_string($buf_pointer, "localvar_server");
+my $channel_name = weechat::buffer_get_string($buf_pointer, "localvar_channel");
+
 my $my_nick = weechat::info_get( 'irc_nick', $servername );                                     # get nick with servername (;freenode.)
 
 if ( grep /^$servername.$channel_name$/, @var_blacklist_channels ) {                            # check for blacklist_channels
@@ -124,9 +134,11 @@
 $string =~ m/^(.*)\t(.*)/;                                                                      # get the nick name: nick[tab]string
 my $nick = $1;                                                                                  # nick with nick_mode and color codes
 my $line = $2;                                                                                  # get written text
+
 $line = weechat::string_remove_color($line,"");                                                 # remove color-codes from line, first
-$modifier_data =~ m/nick_(.*),/;                                                                # get the nick name from modifier_data (without nick_mode and color codes!)
-my $nick_wo_suffix = $1;                                                                        # nickname without nick_suffix
+# get the nick name from modifier_data (without nick_mode and color codes! Take care of tag "prefix_nick_ccc")
+$modifier_data =~ m/(^|,)nick_(.*),/;
+my $nick_wo_suffix = $2;                                                                        # nickname without nick_suffix
 
 if ( lc($nick_wo_suffix) eq lc($my_nick) ){                                                     # this one checks for own messages
   if ( $default_options{var_avail_buffer} ne "all" ){                                           # check for option avail_buffer
@@ -165,7 +177,6 @@
 $nick_mode = "";
 if ( weechat::config_boolean(weechat::config_get("weechat.look.nickmode")) ==  1 and ($nick ne $get_prefix_action) and (index($modifier_data,"notify_private")) == -1){
 #   if ($nick  =~ m/^\@|^\%|^\+|^\~|^\*|^\&|^\!|^\-/) {                                                  # check for nick modes (@%+~*&!-) without colour
-      my $buf_pointer = weechat::buffer_search("irc",$servername . "." . $channel_name);
       my $nick_pointer = weechat::nicklist_search_nick($buf_pointer,"",$nick_wo_suffix);
       $nick_mode = weechat::nicklist_nick_get_string($buf_pointer,$nick_pointer,"prefix");
       my $color_mode = weechat::color( weechat::nicklist_nick_get_string($buf_pointer, $nick_pointer, "prefix_color") );
@@ -177,9 +188,10 @@
 }
 
 # i wrote the message
+#weechat::print("","nick_wo: $nick_wo_suffix");
+#weechat::print("","my_nick: $my_nick");
     if ($nick_wo_suffix eq $my_nick ){                                                                  # i wrote the message
       return $string if check_whitelist_nicks($servername, $my_nick, $nick_wo_suffix);                  # check for whitelist
-
       if ($default_options{var_chat} eq "on"){
 	  my $nick_color = weechat::config_color(weechat::config_get("weechat.color.chat_nick_self"));  # get my nick color
 	  $nick_color = weechat::color($nick_color);
@@ -234,6 +246,7 @@
 
 	    chomp($highlight_words);
 
+#            weechat::print("",$highlight_words);
 	      foreach ( split( /,+/, $highlight_words ) ) {                                     # check for highlight_words
 		  if ($_ eq ""){next;}                                                          # ignore empty string
 		    my $search_string = shell2regex($_);
@@ -255,9 +268,11 @@
 	      }
       }
 	# buffer_autoset is off.
-	if (lc($string) =~ m/(\w.*$my_nick.*)/){						# my name called in string (case insensitiv)?
+        if ( weechat::string_has_highlight($line, $my_nick) >= 1){
+#        if (lc($string) =~ m/(\w.*$my_nick.*)/){                                                # my name called in string (case insensitiv)?
 	    my $color_highlight = weechat::config_color(weechat::config_get("weechat.color.chat_highlight"));
 	    my $color_highlight_bg = weechat::config_color(weechat::config_get("weechat.color.chat_highlight_bg"));
+
 	    my $high_color = weechat::color("$color_highlight,$color_highlight_bg");
 
               if (index($modifier_data,"irc_action") >= 0){                                    # action used (/me)?
@@ -276,7 +291,7 @@
 	}
     } # highlight area finished
 
-return $string if check_whitelist_nicks($servername, $my_nick, $nick_wo_suffix);        # check for whitelist
+return $string if check_whitelist_nicks($servername, $my_nick, $nick_wo_suffix);                # check for whitelist
 # this one check for other nick!!
 if ( $default_options{var_avail_buffer} ne "all" ){                                             # check for option avail_buffer
   if ( index($modifier_data,"notify_message") > -1){                                            # message is public
@@ -304,6 +319,7 @@
 	    if ( weechat::string_has_highlight_regex($line,weechat::config_string(weechat::config_get("weechat.look.highlight_regex"))) eq 1 ){
 		my $color_highlight = weechat::config_color(weechat::config_get("weechat.color.chat_highlight"));
 		my $color_highlight_bg = weechat::config_color(weechat::config_get("weechat.color.chat_highlight_bg"));
+
 		my $high_color = weechat::color("$color_highlight,$color_highlight_bg");
 		$line = colorize_nicks($high_color,$modifier_data,$line);
 		$line = $nick_prefix_with_color . $nick_mode . $high_color . $nick . $nick_suffix_with_color . "\t" . $high_color . $line . weechat::color('reset');
@@ -332,10 +348,10 @@
 sub check_whitelist_nicks{
 my ( $servername, $my_nick, $nick_wo_suffix ) = @_;
   if ( $default_options{var_nicks} ne "" and $default_options{var_own_lines} eq "off" ){          # nicks in option and own_lines = off
-        return 1 unless (grep /^\Q$servername.$nick_wo_suffix\E$/i, @nick_list)             # check other nicks
+        return 1 unless (grep /^\Q$servername.$nick_wo_suffix\E$/i, @nick_list)                   # check other nicks
   }elsif ( $default_options{var_nicks} ne "" and $default_options{var_own_lines} eq "on" ){       # nicks in option and own_lines = on
       if ( $nick_wo_suffix ne $my_nick){                                                          # not my nick!
-        return 1 unless (grep /^\Q$servername.$nick_wo_suffix\E$/i, @nick_list)             # check other nicks
+        return 1 unless (grep /^\Q$servername.$nick_wo_suffix\E$/i, @nick_list)                   # check other nicks
       }
   }elsif( $default_options{var_nicks} eq "" and $default_options{var_own_lines} eq "off" ){       # no nicks and do not color my line?
       if ( $nick_wo_suffix eq $my_nick){                                                          # my nick?
@@ -497,7 +513,7 @@
 }
 # -------------------------------[ init ]-------------------------------------
 # first function called by a WeeChat-script.
-weechat::register($prgname, "Nils Görs <weechatter\@arcor.de>", $version,
+weechat::register($prgname, "Nils Görs <weechatter\@arcor.de>", $version,
                   "GPL3", $description, "", "");
 # check weechat version
   $weechat_version = weechat::info_get("version_number", "");
@@ -512,7 +528,7 @@
 
 $get_prefix_action = weechat::config_string(weechat::config_get("weechat.look.prefix_action"));
 weechat::hook_modifier("weechat_print","colorize_cb", "");
-#weechat::hook_modifier("colorize_text","colorize_cb", "");
+weechat::hook_modifier("colorize_lines","colorize_cb", "");
 
   if (( $weechat_version ne "" ) && ( $weechat_version >= 0x00030400 )){        # v0.3.4?
     $weechat_version = 1;                                                       # yes!