- Recent
- Popular
- Tags (1)
- Subscribers (4)
- Get rxvt-unicode with 256 color support on UbuntuOctober 13 2008
-
rxvt-unicode (commonly called urxvt) already has 88 color support, and for most things, this is fine. But I recently just found the CSApprox plugin for vim, which lets you use Gvim themes in console vim. CSApprox actually does a pretty good job interpolating for 88 colors too, but it is best at 256.
So here’s my build log of compiling rxvt-unicode with the 256 color patch on Ubuntu Hardy, and debianizing (packaging) it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 # I keep all custom deb's here, use any directory you want cd ~/debian-src # Make a place for rxvt-unicode mkdir rxvt-unicode cd rxvt-unicode/ # Get the source apt-get source rxvt-unicode cd rxvt-unicode-8.4/ # Apply 256 color patch, it's included with the source patch -p1 < doc/urxvt-8.2-256color.patch # Make sure you have all depdencies to build it sudo apt-get build-dep rxvt-unicode # Build it dpkg-buildpackage -us -uc -rfakerootThis will actually build three separate packages:
- rxvt-unicode
- rxvt-unicode-lite
- rxvt-unicode-ml
All I care about is rxvt-unicode, but you might want -lite or -ml. If someone more adept in Debian package building than I am can tell me how to just compile one of these versions, that’d be great. :)
Moving along:
1 2 3 4 5 6 # Install it! cd ~/debian-src/rxvt-unico - Making methods immutable in Ruby (or, Death to Monkey Patching)September 17 2008
-
You’ve probably been told that in Ruby classes are always open and any code can come along and redefine your methods in any way it pleases. Indeed, this is true.
Kinda
What’s not true, despite every reference I’ve read saying the contrary, is that you can’t prevent this from happening.
Ruby provides a method_added() callback that is invoked every time a method is added or redefined within a class. It’s part of the Module class, and every Class is a Module. There are also two related callbacks called method_removed() and method_undefined().
This means you could detect when other code has redefined a method, and do something about it! How about redefining that method (again) to point back to your original code? Indeed, this works.
I’ve encapsulated the details of this in a new module I call Immutable. It provides one class method called immutable_method(). Provide it a list of methods you don’t want touched and it’ll make sure they can’t be redefined. Hence, immutable.
It’s on GitHub: http://github.com/up_the_irons/immutable/tree/master
Here’s an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 require 'rubygems' require 'immutable' module Foo include Immutab - Nicely formatted JSON on the command lineSeptember 3 2008
-
You have a URL that outputs JSON, and you want to quickly see its contents from the shell, but nicely formatted, not the raw output wget spits; just do:
1 2 $ wget foo.com/bar.json -O - --quiet | ruby -rubygems -e \ 'require "json"; puts JSON.parse($stdin.gets).to_yaml'I broke it up into two lines for easier reading, but you can type it all out in one line, or better yet, turn it into a shell script with a single URL argument.
- GNU screen with vertical split supportAugust 22 2008
-
Just a quick post here. I recently recompiled screen with vertical split support on Ubuntu 8.04. Here’s how you do it:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 # Install dependencies to build screen sudo apt-get build-dep screen # Create an area to hold the source cd ~/debian-src mkdir screen cd screen # Get the source apt-get source screen # Apply vertical split patch cd screen-4.0.3/ wget http://vsp4sdl.yuggoth.org/wrp_vertical_split_0.3_4.0.2.diff.bz2 bunzip2 wrp_vertical_split_0.3_4.0.2.diff.bz2 patch -p1 < wrp_vertical_split_0.3_4.0.2.diff # Build it! dpkg-buildpackage -us -uc -rfakeroot cd .. # Install it! sudo dpkg -i screen_4.0.3-0.4ubuntu2_amd64.debThat’s it.
- Automatically setting hostname as GNU screen window titleAugust 19 2008
-
I’m starting to put this in ~/.bashrc of all my servers now:
1 2 3 4 5 6 # Set screen window title case "$TERM" in screen) PROMPT_COMMAND='echo -ne "\033k$HOSTNAME\033\\"' ;; esacWhen I log into the machine, the screen window title (which displays on the hard status line, and in turn my urxvt window title bar) automatically changes to the hostname of the machine I’m logged into. I used to set this manually, but now I don’t have to, yay!
If your distro doesn’t set up your environment so ~/.bashrc is sourced upon login, you’ll want to put this into ~/.bash_login instead.
To get this code on a lot of servers at once, save the above snippet to a file called “prompt-command.sh” and execute:
for i in hostname1 hostname2 hostname3; do cat prompt-command.sh | ssh $i 'cat >> ~/.bashrc'; doneOf course, change “hostname1”, “hostname2”, etc… to the real hostnames of your machines.
Cool, huh?
