]> git.alrj.org Git - zsh.d.git/blob - S61_konsoletabs
Unbreak completion on wrapped commands.
[zsh.d.git] / S61_konsoletabs
1 #! /usr/binn/zsh
2
3 # Change konsole tab to current path
4 konsole-rename-path () {
5     if [ "$KONSOLE_DCOP_SESSION" ]
6     then
7         local DIR
8         DIR=${PWD/#${HOME}/\~}
9         dcop ${KONSOLE_DCOP_SESSION} renameSession "$DIR"
10     fi
11 }
12
13 # Change konsole tab to current command
14 konsole-rename-cmd () {
15     if [ "$KONSOLE_DCOP_SESSION" ]
16     then
17         # We don't need to change tab to "cd xyz" or precmd redefinition
18         # Yes, this is a dirty hack
19         if [[ "$1" != \ cd\ \"* && "$1" != \ precmd* ]]
20         then
21             local TXT
22             TXT="${1[0,33]}"
23             if [[ "$1" != "$TXT" ]]
24             then
25                 TXT="${1[0,30]}..."
26             else
27                 TXT="$1"
28             fi
29             dcop ${KONSOLE_DCOP_SESSION} renameSession "$TXT"
30         fi
31     fi
32 }
33
34 precmd_functions+='konsole-rename-path'
35 preexec_functions+='konsole-rename-cmd'
36
37 # On changing directory, when in mc (automatically called).
38 mc_chpwd () {
39     if [ -n "$MC_SID" ]
40     then
41         konsole-rename-path
42     fi
43 }
44