M-A's

technology blog

Wednesday, 30 June 2010

rdesktop from linux into Windows with a ca-fr keyboard layout

[note to myself]

I am using the French Canadian keyboard layout on Ubuntu Lucid and was having a hard time typing "\". Solution:

  • With "Terminal Server Client" GUI and on the "Local Resources" tab, set the keyboard to "ca-fr".
    • Note it's "ca-fr" and not "fr-ca" or "fr_CA" or whatever wrong values I could come up with..!
  • With rdesktop, it's "rdesktop -k fr-ca <hostip>".
    • Note it's "fr-ca" there and not "ca-fr" or "fr_CA". +1 for consistency. Oh well...
Update
Forget about tsclient and rdesktop, I never fully got them to work correctly. Remmina works much better for me. It is based on FreeRDP that uses sane keyboard input. Simply install its ppa since Ubuntu Lucid's version is too old.

    Monday, 14 June 2010

    automatic git mergetool selection based on X availability

    I usually edit code over ssh, when merging, vimdiff is sufficient to me most of the time but when the merge is too complex, kdiff3 does a better job so I NX into the box and start the merge from there. I got tired of using git mergetool=kdiff3 so I wrote this tool. Note that vimdiff is started in a different configuration that would be done in a normal git config merge.tool = vimdiff; cursor is reset to line 0 and the viewport is modified in a more useful format, plus all the 4 buffers are loaded.
    #!/bin/sh
    # Copyright (c) 2010 Marc-Antoine Ruel
    # Automatically select the right merge tool based on X session availability.

    if [ ! "$(git config --global --get mergetool.autodiff.cmd)" ]; then
      echo Setting git config --global merge.tool = autodiff
      git config --global mergetool.autodiff.cmd "`pwd`/autodiff.sh \$BASE \$LOCAL \$REMOTE \$MERGED"
      git config --global merge.tool autodiff
      echo Done.
      exit
    fi

    if [ -z "$DISPLAY" ]; then
      # Start in diff mode, move the viewport down and move up to first line.
      vimdiff -c "wincmd J" -c "0" $4 $2 $1 $3
    else
      # Inside an X session, redirect stderr.
      kdiff3 --auto --L1 "$4 (Base)" --L2 "$4 (Local)" --L3 "$4 (Remote)" -o $4 $1 $2 $3 2> /dev/null
    fi