I found a pretty nice thread in this forum showing how to change the window title of a PuTTY window from within the shell. (Which I can't reference due having less than 5 postings?!?)
I modified the solution a bit to have a function in my zshrc "wt()" changing the window title each time I call it to "$(pwd) @ $(hostname)".
Can I somehow connect this wt-call to my cd-command? Defining an alias doesn't work due to "cd" existing as a certain command, I reckon?
Is it possible to modify or overwrite the standard-cd-definition?
I'm sure it is, I probably just didn't find the proper search-keywords?! :wall:
You don't need this
I guess Your goal is to have refreshed values of $(pwd) and $(hostname) in putty's title?
You can set variable PS1 to execute command every time prompt is being written.
In Your zshrc add
PS1=$PS1"\$(/path/to/script)"
or if You have defined function wt() before that it could look:
PS1=$PS1"\$(wt)"
So - every time You change path, or execute command, function wt() will be run.
This surely works for bash, I think it will work for zsh also...
Ok, I see what's happening. But unfortunately it seems that zsh can't execute commands in PS1 variable. At least I can't find how to do this...
With bash life is a little simplier
And returning to Your first idea, maybe an alias called "ccd" or sth like that, which would look like:
ccd () {
cd $@
wl
}
added to .zshrc file... Works, but requires using "ccd" instead of "cd"
Rubbish zsh Unfortunately, I'm not (yet) to decide which shell to use on our systems.
But I found another way of doing it. I must confess, I don't understand that whole zsh-syntax, but I was able to modify the solution presented in the zsh-FAQ section 3.6.
Putting the following into you zshrc results in displaying "WorkingDir @ Host Username" in the PuTTY-window-title after each cd:
(This rule of not being allowed to post URLs in the beginning is just pathetic. What is the use of that? I know cannot reference the source of my solution...)
Anyway, many thanks sulti!
---------- Post updated at 07:42 AM ---------- Previous update was at 07:41 AM ----------
Yay, I now reached my first 5 postings and so I now CAN post that URL of source of mine o_O