#! /usr/binn/zsh # Change konsole tab to current path konsole-rename-path () { if [ "$KONSOLE_DCOP_SESSION" ] then local DIR DIR=${PWD/#${HOME}/\~} SDIR="${DIR[-28,-1]}" if [[ "$SDIR" != "$DIR" ]] then SDIR="...${DIR[-25,-1]}" else SDIR="$DIR" fi dcop ${KONSOLE_DCOP_SESSION} renameSession "$SDIR" fi } # Change konsole tab to current command konsole-rename-cmd () { if [ "$KONSOLE_DCOP_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" ]] then TXT="${1[0,30]}..." else TXT="$1" fi dcop ${KONSOLE_DCOP_SESSION} renameSession "$TXT" fi fi } precmd_functions+='konsole-rename-path' preexec_functions+='konsole-rename-cmd' # On changing directory, when in mc (automatically called). mc_chpwd () { if [ -n "$MC_SID" ] then konsole-rename-path fi }