-#! /usr/binn/zsh
+#! /usr/bin/zsh
# Change konsole tab to current path
konsole-rename-path () {
- if [ "$KONSOLE_DCOP_SESSION" ]
+ if [ -n "$KONSOLE_DCOP_SESSION" -o -n "$KONSOLE_DBUS_SESSION" ]
then
local DIR
- DIR=${PWD/#${HOME}/\~}
- dcop ${KONSOLE_DCOP_SESSION} renameSession "$DIR"
+ DIR=`print -P "%28<...<%~"`
+ if [ -n "$KONSOLE_DCOP_SESSION" ]
+ then
+ dcop ${KONSOLE_DCOP_SESSION} renameSession "$DIR"
+ elif [ -n "$KONSOLE_DBUS_SESSION" ]
+ then
+ qdbus ${KONSOLE_DBUS_SERVICE} ${KONSOLE_DBUS_SESSION} setTitle 0 "$DIR" > /dev/null 2>&1
+ qdbus ${KONSOLE_DBUS_SERVICE} ${KONSOLE_DBUS_SESSION} setTitle 1 "$DIR" > /dev/null 2>&1
+ fi
fi
}
# Change konsole tab to current command
konsole-rename-cmd () {
- if [ "$KONSOLE_DCOP_SESSION" ]
+ if [ -n "$KONSOLE_DCOP_SESSION" -o -n "$KONSOLE_DBUS_SESSION" ]
then
# We don't need to change tab to "cd xyz" or precmd redefinition
# Yes, this is a dirty hack
if [[ "$1" != \ cd\ \"* && "$1" != \ precmd* ]]
then
- local TXT
- TXT="${1[0,33]}"
- if [[ "$1" != "$TXT" ]]
+ local CMD
+ CMD=`print -P "%30>...>$1"`
+
+ if [ -n "$KONSOLE_DCOP_SESSION" ]
+ then
+ dcop ${KONSOLE_DCOP_SESSION} renameSession "$CMD"
+ elif [ -n "$KONSOLE_DBUS_SESSION" ]
then
- TXT="${1[0,30]}..."
- else
- TXT="$1"
+ qdbus ${KONSOLE_DBUS_SERVICE} ${KONSOLE_DBUS_SESSION} setTitle 0 "$CMD" > /dev/null 2>&1
+ qdbus ${KONSOLE_DBUS_SERVICE} ${KONSOLE_DBUS_SESSION} setTitle 1 "$CMD" > /dev/null 2>&1
fi
- dcop ${KONSOLE_DCOP_SESSION} renameSession "$TXT"
fi
fi
}