Archive for May, 2008

dre on the LKDC

Wednesday, May 14th, 2008

So dre has done a great overview of the LKDC in Leopard, including a more detailed wiki page. There really isn’t enough info out there about the LKDC, and it’s quite awesome technology.

useful screen bash function

Wednesday, May 14th, 2008

So I pretty much live in screen permanently these days, and there are a gazillion awesome introductions out there to screen that describe the amazing advantages of screen.

One thing that has been a minor niggle has been the clunky way you pick which screen session you wish to reattach to if you have multiple sessions active, so I whipped up this bash function that I’ve been finding really useful.

function scr() {

  if [ ! $1 ]; then

    screen -D -R

  else

    i=1

    for j in $(screen -list | awk --posix '/^[[:space:]]*[[:digit:]]{2,}.*$/{print $1}'); do

      screens[${i}]=$j

      let i=i+1

    done

    # test if integer

    if ! [ $1 -eq $1 2> /dev/null ]; then

      echo "You must supply an integer as the argument"

    elif [ $1 -eq 0 ]; then

      echo "screens list count starts at 1, not zero."

    elif [[ ${1} -gt ${#screens[@]} ]]; then

      echo "only ${#screens[@]} screens exist"

      screen -list

    else

      screen -D -R ${screens[$1]}

    fi

  fi

}

So you can basically go scr to reattach to a single screen session, scr 1 to reattach to the first, scr 2 to reattach to the second, etc etc.

I’m kind of expecting someone to pipe up now and point out a much easier way… :)