SSH to same directory on remote server

My local dev environment matches the file structure of our dev server. Its convenient to be able to ssh to the same directory on the development server.

I added this to my ~/.profile.

1
2
3
function dev01 {
ssh dev01 -t "cd $PWD; bash --login"
}

Then all I have to do is type dev01 on my local terminal and it opens a shell on the server in the same directory. If the directory is not found, it just drops you back into ~/