Sunday, March 9, 2008

Getting GNU screen to show the current directory or command as the tab title

Put the following in your .bashrc:
#if in screen, update session stuff
if [[ $TERM == 'screen' ]]; then
function rename_screen_tab () { echo -ne "\x1bk$@\x1b\\"; return 0; }
trap 'echo -ne "\ek${USER:0:1}@${HOSTNAME:0:1}#$BASH_COMMAND\e\\"' DEBUG
PROMPT_COMMAND='rename_screen_tab ${USER:0:1}@${HOSTNAME:0:1}:${PWD##*/}'
fi

It shortens your user name to one letter, the host you are on to one letter, and the path to the lowest directory.

Example: b@p#vim extract_link

Monday, November 5, 2007

Correctly creating Octave sparse matrix files

If you are generating sparse matrix files to load into Octave, here is the format:
# name: NAME_OF_MATRIX
# type: sparse matrix
# nnz: NUMBER_OF_NONZERO_ENTRIES
# rows: NUMBER_OF_ROWS
# columns: NUMBER_OF_COLUMNS
1 1 1
2 1 3

Note: Each line is (row, column, value). The entries should first be sorted by column number, then by row.