You are not logged in.
oh-my-zsh users, where do you put your custom preexec/precmd stuff?
If I understand correctly, stuff in lib shouldn't contain user-specific stuff, although lib/termsupport.zsh is where preexec and precmd are defined.
so if we have custom logic, where should we put it?
here's my current code. The idea is that many programs (mplayer is one, but I'll add more) warrant an mpc toggle before and after they run (if mpd is running, that is)
my code currently works fine, but it doesn't feel organized well.
22:43:35 dieter@ws .oh-my-zsh dieter ? cat lib/termsupport.zsh
(....)
case "$TERM" in
xterm*|rxvt*)
preexec () {
if [[ $1 =~ ^mplayer ]] && mpc 2>/dev/null | grep -q playing
then
toggle=1
mpc toggle
fi
print -Pn "\e]0;%n${host} $1\a" # xterm
}
precmd () {
if [ "$toggle" = 1 ]
then
mpc toggle
toggle=0
fi
print -Pn "\e]0;%n${host} %~\a" # xterm
}
;;
screen*)
preexec () {
local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]}
echo -ne "\ek$CMD\e\\"
print -Pn "\e]0;%n${host} $1\a" # xterm
}
precmd () {
echo -ne "\ekzsh\e\\"
print -Pn "\e]0;%n${host} %~\a" # xterm
}
;;
esac
Last edited by Dieter@be (2010-11-24 21:47:08)
< Daenyth> and he works prolifically
4 8 15 16 23 42
Offline