I ended up writing a script because it seems there is no solution on the net:
#!/bin/bash CMD=$1 #DIR=$(readlink -ve "/proc/$PPID/cwd") DIR=`pwd` PRIVILEGE='$' #echo $DIR [ $# -eq 0 -o $# -gt 1 ] && { echo -e "Usage:\n\t $0 command\n\t Command should be enclosed in quotations"; exit 1; } if [ $UID -ne 0 ]; then echo "Please run this script with sudo:"; echo "sudo $0 $*"; exit 1; fi mkdir -p /result #echo $DIR PATTERN="^\/home\/\w+$" if [[ $DIR =~ $PATTERN ]] || [ $DIR == '/root' ];]]; then DIR='~'; else DIR=`basename $PWD`; fi echo $DIR if [ $UID -eq 0 ]; then PRIVILEGE='#'; fi #echo $PRIVILEGE NUM=`ls -vr /result/ | head -1 | sed -e 's/\..*$//'` if [ ! -n "$NUM" ]; then NUM=1; else ((NUM++)); fi convert -font DejaVu-Sans-Mono-Book -pointsize 16 label:"$(echo "[`id -u -n`@`hostname` $DIR]$PRIVILEGE $CMD";$CMD)" /result/$NUM.png echo $NUM.png