You are not logged in.
Pages: 1
I am trying to rewrite the preexec method in zsh but I am having some difficulties. This is what I've got so far:
preexec () {
$command = $1
if [$command == "ssh 192.168.0.100"]; then
$command = "Server"
fi
print -Pn "\ek$command\e\\"
}
But it doesn't work. It says:
preexec:1: command not found: =
preexec:2: = not found
Offline
What do you want to do? If $command is equal to that string, replace its value with "Server"?
You should be doing:
command="Server"
then (without spaces around the = and with no $ at the beginning)
(lambda ())
Offline
What I want to do is change the screen title to the command that's running. But if it's ssh * I want it to be server. The print -Pn statement changes the title.
I now have:
preexec () {
$command = $1
if [$command == "ssh 192.168.0.100"]; then
command="Server"
fi
print -Pn "\ek$command\e\\"
}
But that doesnt work as wel.
Offline
preexec () {
command=$1
if [[ $command == "ssh 192.168.0.100" ]]; then
command="Server"
fi
print -Pn "\ek$command\e\\"
}
I guess it should work now. When you're setting a parameter value, you shouldn't use the dollar sign nor put spaces around the equal sign. And preferably, use [[ and ]] when using the if statement with zsh.
edit: typo
Last edited by andre.ramaciotti (2009-03-23 15:19:48)
(lambda ())
Offline
Offline
Pages: 1