Skip to content

Instantly share code, notes, and snippets.

function rat {
# change part of pwd path, and cd to it
# example:
# /usr/lib/foo$ rat li src
# /usr/src/foo$
local cd=$(echo $PWD | awk -v q="$*" -F\/ '
BEGIN { l = split(q,a," ") }
{
for( i=1;i<=NF;i++ ) {
for( j=1;j<=l;j=j+2 ) {
@rupa
rupa / screc.sh
Created June 1, 2009 23:02
screencaps to video
#!/bin/bash
# OSX requires Quicktime Pro, linux requires scrot and mencoder
# jpg faster/png higher quality
FORMAT=jpg
usage() {
cat <<!
use: $(basename $0) -c <path/to/empty/folder> [seconds]
$(basename $0) -o <path/to/empty/folder>
@rupa
rupa / README
Created February 23, 2009 07:08
experimental directory navigation
# cd to the shortest, first, non-hidden dir under $root matching all args
#
# USE:
# alias alias=root=root __h [--]
#
# DESCRIPTION
#
# This provides a helper function (__h) meant to be used with aliases to do
# smart directory navigation
#
@rupa
rupa / j.sh
Created February 16, 2009 17:28
# maintains a jump-list of directories you actually use
# old directories eventually fall off the list
# inspired by http://wiki.github.com/joelthelion/autojump
# and something similar i had - but i could never get the dir list right.
#
# INSTALL:
# source into .bashrc under your '[-z "$PS1" ] || return' line
# cd around for a while
#
# USE:
@rupa
rupa / ewmh
Created January 29, 2009 16:48
EWMH
this module is mostly for making your workspace switcher function properly in GNOMe, KDE, or any other EWMH desktop.
import XMonad.Hooks.EwmhDesktops
This module only has three user facing functions.
There is a function for your layout hook that tells xmonad what EWMH is doing. It lets you click/drag windows in the workspace switcher:
myLayout = ewmhDesktopsLayout
@rupa
rupa / gist:47475
Created January 15, 2009 16:41
lan detection
#!/bin/bash
function wireless {
case "$(uname)" in
Linux)/sbin/iwconfig 2>/dev/null | awk -F\" '/ESSID/&&!/NOT READY/{print $2}';;
Darwin)/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I | awk '/ SSID/{print $2}';;
esac
}
function int_ip {