Scripting Tmux Layouts

Tmux is an awesome replacement for Screen. I have a couple of standard terminal layouts for programming. One of them is show below.

  • Vim editor on the left.
  • Top right pane has the bpython interpreter. 
  • Bottom right pane has the bash prompt. 

I have a small tmux script in my ~/.tmux/pdev file that has the following lines

selectp -t 0              # Select pane 0
splitw -h -p 50 'bpython' # Split pane 0 vertically by 50%
selectp -t 1              # Select pane 1
splitw -v -p 25           # Split pane 1 horizontally by 25%
selectp -t 0              # Select pane 0

In my tmux.conf file I have bound <prefix>+P to sourcing this file. So now anytime I want to launch my python dev layout, I hit <prefix>+<shift>+p. 

bind P source-file ~/.tmux/pdev

Downloading Specific Filetypes using 'wget'

I decided to prepare myself for the Intro to AI, a free online course offered by Stanford. I found the course website: http://www.stanford.edu/class/cs221/schedule.html and wanted to download all the slides. 

It's time to pull all the ppt files from that page.

wget -r -A.ppt http://www.stanford.edu/class/cs221/notes/ 

This created a tree of empty directories with one of them that had all the ppt files. Time to clean up the empty folders:

find -depth -type d -empty -exec rmdir {} \;

Ta-da! Empty folders are gone. 

Remember if you are typing a command more than once in succession there is a way to automate it. 

Synchronize Panes in Tmux

Tmux is an alternative for screen. For anyone who doesn't know screen, it is a terminal multiplexer which means, it allow multiple windows in terminal. It can split your window into multiple panes (vertical/horizontal), detach a session which can be attached at a later time. Detach/Attach is very useful for running a job in a remote server without having to keep the ssh open the whole time. 

Tmux can be configured by  ~/.tmux.conf file.
My prefix key is Ctrl-q.
Synchronizing panes:
If you want to send your keystrokes to all the panes in your tmux window: 
<prefix> :setw synchronize-panes
In my case I do:
Ctrl-q:setw synchronize-panes
This is immensely useful if you want to execute the same set of commands on multiple servers.

Why do I hate Gnome?

I've been using Ubuntu Linux on my netbook for the past couple of days and I'm quite pleased with the whole experience, except for the initial issues (I just won't trust the auto-update).

Ubuntu uses the Gnome desktop environment by default with a little bit of tweaking. Gnome UI designers have a sense of aesthetic cognizance to their designs. I've always appreciated the crisp icons and the polished dialogs. I've been known to throw around the word stunning, quite generously, while describing Gnome. 

All these initial infatuations almost made me forget the reasons why I abandoned Gnome a few years ago. I  hate the absence of a central control center to tweak the default behavior of Gnome. There is however a severely handicapped version called gconf-editor which is like a terrible cousin of Windows Registry. So now if you want sloppy focus on gnome that doesn't raise your window when you click on it, you just have to do the following simple steps:

  1. Open gconf-editor
  2. apps
  3. metacity
  4. general
  5. raise on click (uncheck)
Quite intuitive wouldn't you agree? 

Oh you want to enable compositing, so your gnome-do can have some slick skins, here's how you achieve that: 

  1. Open gconf-editor
  2. apps
  3. metacity
  4. general
  5. compositing_manager (check)
Why? Why would you think this is more intuitive than having a simple GUI driven control center? I'm told this was a conscious choice by Gnome developers because giving choices tend to confuse their users.

If you think your users are idiots, only idiots will use it.

No wonder Linus was pissed at Gnome and started recommending KDE.

Ubuntu and I have some trust issues

I've been exclusively using Meego on my netbook and I was moderately happy with what it provided. So I did what any self-respecting hacker would do - I tried to make it better. Well, we all know how that usually ends. I managed to uninstall every single kernel in the system and rendered the system unbootable. Taking this as an opportunity I decided to try a grown-up OS. Enter Ubuntu into the picture.

I've heard nothing but great things about Ubuntu and I fuckin' hated it. Why? Because it was stealing all the limelight from the ever superior Mandriva (my favorite distro). So I got the installation process going which was smooth but surprisingly it didn't give me the option to keep my old partition, it was an all or nothing approach (grown up OS my ass). I had all my "stuff" backed up, so I decided to repartition my disk. It even detected my Broadcom wireless card and offered to install a proprietary driver for it. Wireless was working and the visual candy was stunning. I've never seen such a beautiful font set on my computer before. All the visual components looked hand crafted and the notifications were done with style. It was just a gorgeous piece of artwork. Visually stunning (if you didn't get that part already). 

I was quite pleased with the decision to go with Ubuntu and was having some fleeting thoughts about replacing Mandriva on my desktop. Around 15 minutes in my playful prodding and poking, I was notified that Software Updates were available. After it successfully installed the updates and rebooted the computer (some Kernel updates were involved), I couldn't connect to the internet anymore. The network icon wouldn't show up on my system tray anymore. After some googling I managed to find the "Additional Drivers" program which installed the Broadcom Drivers once again. But this time it would show me the available networks but wouldn't connect to any of them. The system update had successfully screwed over the authentication routine for connecting to WPA2 networks. I tried to plug in my network cable to the ethernet port only to find out the system hadn't recognized the existence of an ethernet port. Are you kidding me? Have you heard of a little thing called hot-plugging? I've been spoiled by Mandriva that can automatically choose between the wireless card and the network cable on the fly, depending on which was available. Now I had to muck around the network interface files to even get my ethernet card detected. How hard is it to develop a Central Control Center that can manage your hardware? After getting that to work, I tried at least 10 different methods described on various forums to get the wireless chipset to work again without any success. I gave up after 10 hours of tweaking and started trying other OSes. Here is a list:
  • Fedora looked nice but wouldn't connect to internet. Same problem as Ubuntu, but this time, it wouldn't offer to download proprietary drivers. 
  • Mandriva image hangs up in the middle of booting (I'm personally embarrassed by this). Btw, Mandriva has to be the ugliest of all the OSes. Seriously man, you gotta up the ante a little bit if you want to stay in this game.
  • Mint OS same as Ubuntu, only it looked even more gorgeous. I might try this out in the future. 
I should've tried Arch Linux but I was too tired at this point. So I did what any self-respecting hacker would do..... I re-installed Ubuntu and rejected the offer to auto-update my system. Now I have wireless internet and a usable desktop that looks pretty.

Ubuntu had so much potential. I will always remember today as the day I almost replaced my desktop Mandriva with Ubuntu. Maybe next time.

Hands on Intro - Git

Today I presented in the Salt Lake Linux User Group meeting. The topic was "Hands on Intro - Git". It went well and I actually enjoyed it quite a bit. I choked twice once while trying to explain how to git apply patches that you receive via email, but then recovered from it with some help from the audience. But the second time I choked while trying to explain how to pull from multiple remote repositories, I couldn't recover from that. I do that so rarely it never occurred to me. Oh well, the first time is the hardest.

 
Off to prepare for the talk tomorrow at the Utah Python Group. I'm presenting "Hands on Into - PyQt4". 
 
Here are the slides from that talk. LaTeX Source: https://github.com/amjith/git_present